start = $start; $this->end = $end; $this->error = $error; $this->retry_count = 0; } /** * Convert this object to a plain array for JSON serialization. */ #[\ReturnTypeWillChange] public function jsonSerialize() { return array( 'start' => $this->start, 'end' => $this->end, 'error' => $this->error, 'retry_count' => $this->retry_count, ); } /** * This is intended to be the reverse of JsonSerializable->jsonSerialize. * * @param mixed $data The data to turn into an object. * * @return Speed_Score_Graph_History_Request */ public static function jsonUnserialize( $data ) { $object = new Speed_Score_Graph_History_Request( $data['start'], $data['end'], $data['error'] ); if ( ! empty( $data['retry_count'] ) ) { $object->retry_count = intval( $data['retry_count'] ); } return $object; } /** * Return the cache prefix. * * @return string */ protected static function cache_prefix() { return 'jetpack_boost_speed_scores_graph_history_'; } /** * Send a Speed History request to the API. * * @return true|\WP_Error True on success, WP_Error on failure. */ public function execute() { $response = Boost_API::get( 'speed-scores-history', array( 'start' => $this->start, 'end' => $this->end, ) ); if ( is_wp_error( $response ) ) { $this->status = 'error'; $this->error = $response->get_error_message(); $this->store(); return $response; } return $response; } }