PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/values/oauth/oauth-token.php +14 -4 18.228.5 View file →
@@ -45,8 +45,15 @@
45 45 */
46 46 public $created_at;
47 47
48 48 /**
49 + * The number of times we've gotten an error trying to refresh this token.
50 + *
51 + * @var int
52 + */
53 + public $error_count;
54 +
55 + /**
49 56 * OAuth_Token constructor.
50 57 *
51 58 * @param string $access_token The access token.
52 59 * @param string $refresh_token The refresh token.
@@ -52,12 +59,13 @@
52 59 * @param string $refresh_token The refresh token.
53 60 * @param int $expires The date and time at which the token will expire.
54 61 * @param bool $has_expired Whether or not the token has expired.
55 62 * @param int $created_at The timestamp of when the token was created.
63 + * @param int $error_count The number of times we've gotten an error trying to refresh this token.
56 64 *
57 65 * @throws Empty_Property_Exception Exception thrown if a token property is empty.
58 66 */
59 - public function __construct( $access_token, $refresh_token, $expires, $has_expired, $created_at ) {
67 + public function __construct( $access_token, $refresh_token, $expires, $has_expired, $created_at, $error_count = 0 ) {
60 68
61 69 if ( empty( $access_token ) ) {
62 70 throw new Empty_Property_Exception( 'access_token' );
63 71 }
@@ -63,9 +71,9 @@
63 71 }
64 72
65 73 $this->access_token = $access_token;
66 74
67 - if ( empty( $access_token ) ) {
75 + if ( empty( $refresh_token ) ) {
68 76 throw new Empty_Property_Exception( 'refresh_token' );
69 77 }
70 78
71 79 $this->refresh_token = $refresh_token;
@@ -75,14 +83,15 @@
75 83 }
76 84
77 85 $this->expires = $expires;
78 86
79 - if ( \is_null( $has_expired ) ) {
87 + if ( $has_expired === null ) {
80 88 throw new Empty_Property_Exception( 'has_expired' );
81 89 }
82 90
83 91 $this->has_expired = $has_expired;
84 92 $this->created_at = $created_at;
93 + $this->error_count = $error_count;
85 94 }
86 95
87 96 /**
88 97 * Creates a new instance based on the passed response.
@@ -98,9 +107,9 @@
98 107 $response->getToken(),
99 108 $response->getRefreshToken(),
100 109 $response->getExpires(),
101 110 $response->hasExpired(),
102 - \time()
111 + \time(),
103 112 );
104 113 }
105 114
106 115 /**
@@ -123,7 +132,8 @@
123 132 'refresh_token' => $this->refresh_token,
124 133 'expires' => $this->expires,
125 134 'has_expired' => $this->has_expired(),
126 135 'created_at' => $this->created_at,
136 + 'error_count' => $this->error_count,
127 137 ];
128 138 }
129 139 }