Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../includes/vendor/tool
File: RuntimeVersion.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace AmpProject;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Queries https://cdn.ampproject.org/rtv/metadata for the latest AMP runtime version. Uses a stale-while-revalidate
[5] Fix | Delete
* caching strategy to avoid refreshing the version.
[6] Fix | Delete
*
[7] Fix | Delete
* More details: https://cdn.ampproject.org/rtv/metadata returns the following metadata:
[8] Fix | Delete
*
[9] Fix | Delete
* <pre>
[10] Fix | Delete
* {
[11] Fix | Delete
* "ampRuntimeVersion": "CURRENT_PROD",
[12] Fix | Delete
* "ampCssUrl": "https://cdn.ampproject.org/rtv/CURRENT_PROD/v0.css",
[13] Fix | Delete
* "canaryPercentage": "0.1",
[14] Fix | Delete
* "diversions": [
[15] Fix | Delete
* "CURRENT_OPTIN",
[16] Fix | Delete
* "CURRENT_1%",
[17] Fix | Delete
* "CURRENT_CONTROL"
[18] Fix | Delete
* ]
[19] Fix | Delete
* }
[20] Fix | Delete
* </pre>
[21] Fix | Delete
*
[22] Fix | Delete
* where:
[23] Fix | Delete
*
[24] Fix | Delete
* <ul>
[25] Fix | Delete
* <li> CURRENT_OPTIN: is when you go to https://cdn.ampproject.org/experiments.html and toggle "dev-channel". It's
[26] Fix | Delete
* the earliest possible time to get new code.</li>
[27] Fix | Delete
* <li> CURRENT_1%: 1% is the same code as opt-in that we're now comfortable releasing to 1% of the population.</li>
[28] Fix | Delete
* <li> CURRENT_CONTROL is the same thing as production, but with a different URL. This is to compare experiments
[29] Fix | Delete
* against, since prod's immutable caching would affect metrics.</li>
[30] Fix | Delete
* </ul>
[31] Fix | Delete
*
[32] Fix | Delete
* @package ampproject/amp-toolbox
[33] Fix | Delete
*/
[34] Fix | Delete
final class RuntimeVersion
[35] Fix | Delete
{
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Option to retrieve the latest canary version data instead of the production version data.
[39] Fix | Delete
*
[40] Fix | Delete
* @var string
[41] Fix | Delete
*/
[42] Fix | Delete
const OPTION_CANARY = 'canary';
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Endpoint to query for retrieving the runtime version data.
[46] Fix | Delete
*/
[47] Fix | Delete
const RUNTIME_METADATA_ENDPOINT = 'https://cdn.ampproject.org/rtv/metadata';
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Transport to use for remote requests.
[51] Fix | Delete
*
[52] Fix | Delete
* @var RemoteGetRequest
[53] Fix | Delete
*/
[54] Fix | Delete
private $remoteRequest;
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Instantiate a RuntimeVersion object.
[58] Fix | Delete
*
[59] Fix | Delete
* @param RemoteGetRequest $remoteRequest Transport to use for remote requests.
[60] Fix | Delete
*/
[61] Fix | Delete
public function __construct(RemoteGetRequest $remoteRequest)
[62] Fix | Delete
{
[63] Fix | Delete
$this->remoteRequest = $remoteRequest;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Returns the version of the current AMP runtime release.
[68] Fix | Delete
*
[69] Fix | Delete
* Pass [ canary => true ] to get the latest canary version.
[70] Fix | Delete
*
[71] Fix | Delete
* @param array $options Optional. Associative array of options.
[72] Fix | Delete
* @return string Version string of the AMP runtime.
[73] Fix | Delete
*/
[74] Fix | Delete
public function currentVersion($options = [])
[75] Fix | Delete
{
[76] Fix | Delete
$response = $this->remoteRequest->get(self::RUNTIME_METADATA_ENDPOINT);
[77] Fix | Delete
$statusCode = $response->getStatusCode();
[78] Fix | Delete
[79] Fix | Delete
if ($statusCode < 200 || $statusCode >= 300) {
[80] Fix | Delete
return '0';
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
$metadata = json_decode($response->getBody());
[84] Fix | Delete
[85] Fix | Delete
$version = (! empty($options['canary']))
[86] Fix | Delete
? $metadata->diversions[0]
[87] Fix | Delete
: $metadata->ampRuntimeVersion;
[88] Fix | Delete
[89] Fix | Delete
return $this->padVersionString($version);
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Pad the version string to the required length.
[94] Fix | Delete
*
[95] Fix | Delete
* @param string $version Version string to pad.
[96] Fix | Delete
* @return string Padded version string.
[97] Fix | Delete
*/
[98] Fix | Delete
private function padVersionString($version)
[99] Fix | Delete
{
[100] Fix | Delete
return str_pad($version, 15, '0');
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Append the runtime version to the host URL.
[105] Fix | Delete
*
[106] Fix | Delete
* @param string $host Host domain to use.
[107] Fix | Delete
* @param string $version Version to use.
[108] Fix | Delete
* @return string Runtime version URL.
[109] Fix | Delete
*/
[110] Fix | Delete
public static function appendRuntimeVersion($host, $version)
[111] Fix | Delete
{
[112] Fix | Delete
return "{$host}/rtv/{$version}";
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function