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/wordpres.../src/values/oauth
File: oauth-token.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Values\OAuth;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Exceptions\OAuth\Tokens\Empty_Property_Exception;
[4] Fix | Delete
use YoastSEO_Vendor\League\OAuth2\Client\Token\AccessTokenInterface;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Class OAuth_Token
[8] Fix | Delete
*/
[9] Fix | Delete
class OAuth_Token {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* The access token.
[13] Fix | Delete
*
[14] Fix | Delete
* @var string
[15] Fix | Delete
*/
[16] Fix | Delete
public $access_token;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The refresh token.
[20] Fix | Delete
*
[21] Fix | Delete
* @var string
[22] Fix | Delete
*/
[23] Fix | Delete
public $refresh_token;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The expiration date.
[27] Fix | Delete
*
[28] Fix | Delete
* @var int
[29] Fix | Delete
*/
[30] Fix | Delete
public $expires;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Whether or not the token has expired.
[34] Fix | Delete
*
[35] Fix | Delete
* @var bool
[36] Fix | Delete
*/
[37] Fix | Delete
public $has_expired;
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* The timestamp at which the token was created.
[41] Fix | Delete
*
[42] Fix | Delete
* @var int
[43] Fix | Delete
*/
[44] Fix | Delete
public $created_at;
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* The number of times we've gotten an error trying to refresh this token.
[48] Fix | Delete
*
[49] Fix | Delete
* @var int
[50] Fix | Delete
*/
[51] Fix | Delete
public $error_count;
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* OAuth_Token constructor.
[55] Fix | Delete
*
[56] Fix | Delete
* @param string $access_token The access token.
[57] Fix | Delete
* @param string $refresh_token The refresh token.
[58] Fix | Delete
* @param int $expires The date and time at which the token will expire.
[59] Fix | Delete
* @param bool $has_expired Whether or not the token has expired.
[60] Fix | Delete
* @param int $created_at The timestamp of when the token was created.
[61] Fix | Delete
* @param int $error_count The number of times we've gotten an error trying to refresh this token.
[62] Fix | Delete
*
[63] Fix | Delete
* @throws Empty_Property_Exception Exception thrown if a token property is empty.
[64] Fix | Delete
*/
[65] Fix | Delete
public function __construct( $access_token, $refresh_token, $expires, $has_expired, $created_at, $error_count = 0 ) {
[66] Fix | Delete
[67] Fix | Delete
if ( empty( $access_token ) ) {
[68] Fix | Delete
throw new Empty_Property_Exception( 'access_token' );
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$this->access_token = $access_token;
[72] Fix | Delete
[73] Fix | Delete
if ( empty( $refresh_token ) ) {
[74] Fix | Delete
throw new Empty_Property_Exception( 'refresh_token' );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
$this->refresh_token = $refresh_token;
[78] Fix | Delete
[79] Fix | Delete
if ( empty( $expires ) ) {
[80] Fix | Delete
throw new Empty_Property_Exception( 'expires' );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
$this->expires = $expires;
[84] Fix | Delete
[85] Fix | Delete
if ( \is_null( $has_expired ) ) {
[86] Fix | Delete
throw new Empty_Property_Exception( 'has_expired' );
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$this->has_expired = $has_expired;
[90] Fix | Delete
$this->created_at = $created_at;
[91] Fix | Delete
$this->error_count = $error_count;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Creates a new instance based on the passed response.
[96] Fix | Delete
*
[97] Fix | Delete
* @param AccessTokenInterface $response The response object to create a new instance from.
[98] Fix | Delete
*
[99] Fix | Delete
* @return OAuth_Token The token object.
[100] Fix | Delete
*
[101] Fix | Delete
* @throws Empty_Property_Exception Exception thrown if a token property is empty.
[102] Fix | Delete
*/
[103] Fix | Delete
public static function from_response( AccessTokenInterface $response ) {
[104] Fix | Delete
return new self(
[105] Fix | Delete
$response->getToken(),
[106] Fix | Delete
$response->getRefreshToken(),
[107] Fix | Delete
$response->getExpires(),
[108] Fix | Delete
$response->hasExpired(),
[109] Fix | Delete
\time()
[110] Fix | Delete
);
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* Determines whether or not the token has expired.
[115] Fix | Delete
*
[116] Fix | Delete
* @return bool Whether or not the token has expired.
[117] Fix | Delete
*/
[118] Fix | Delete
public function has_expired() {
[119] Fix | Delete
return ( \time() >= $this->expires ) || $this->has_expired === true;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Converts the object to an array.
[124] Fix | Delete
*
[125] Fix | Delete
* @return array The converted object.
[126] Fix | Delete
*/
[127] Fix | Delete
public function to_array() {
[128] Fix | Delete
return [
[129] Fix | Delete
'access_token' => $this->access_token,
[130] Fix | Delete
'refresh_token' => $this->refresh_token,
[131] Fix | Delete
'expires' => $this->expires,
[132] Fix | Delete
'has_expired' => $this->has_expired(),
[133] Fix | Delete
'created_at' => $this->created_at,
[134] Fix | Delete
'error_count' => $this->error_count,
[135] Fix | Delete
];
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function