PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/google/auth/src/Middleware/AuthTokenMiddleware.php +14 -14 1.1.1 → 1.4.2 View file →
@@ -14,16 +14,16 @@
14 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 15 * See the License for the specific language governing permissions and
16 16 * limitations under the License.
17 17 */
18 -namespace Dudlewebs\WPMCS\Google\Auth\Middleware;
18 +namespace Dudlewebs\WPMCS\GCP\Google\Auth\Middleware;
19 19
20 -use Dudlewebs\WPMCS\Google\Auth\FetchAuthTokenCache;
21 -use Dudlewebs\WPMCS\Google\Auth\FetchAuthTokenInterface;
22 -use Dudlewebs\WPMCS\Google\Auth\GetQuotaProjectInterface;
23 -use Dudlewebs\WPMCS\Google\Auth\UpdateMetadataInterface;
24 -use Dudlewebs\WPMCS\GuzzleHttp\Psr7\Utils;
25 -use Dudlewebs\WPMCS\Psr\Http\Message\RequestInterface;
20 +use Dudlewebs\WPMCS\GCP\Google\Auth\FetchAuthTokenCache;
21 +use Dudlewebs\WPMCS\GCP\Google\Auth\FetchAuthTokenInterface;
22 +use Dudlewebs\WPMCS\GCP\Google\Auth\GetQuotaProjectInterface;
23 +use Dudlewebs\WPMCS\GCP\Google\Auth\UpdateMetadataInterface;
24 +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7\Utils;
25 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\RequestInterface;
26 26 /**
27 27 * AuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header
28 28 * provided by an object implementing FetchAuthTokenInterface.
29 29 *
@@ -54,12 +54,12 @@
54 54 /**
55 55 * Creates a new AuthTokenMiddleware.
56 56 *
57 57 * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
58 - * @param callable $httpHandler (optional) callback which delivers psr7 request
59 - * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
58 + * @param callable|null $httpHandler (optional) callback which delivers psr7 request
59 + * @param callable|null $tokenCallback (optional) function to be called when a new token is fetched.
60 60 */
61 - public function __construct(FetchAuthTokenInterface $fetcher, callable $httpHandler = null, callable $tokenCallback = null)
61 + public function __construct(FetchAuthTokenInterface $fetcher, ?callable $httpHandler = null, ?callable $tokenCallback = null)
62 62 {
63 63 $this->fetcher = $fetcher;
64 64 $this->httpHandler = $httpHandler;
65 65 $this->tokenCallback = $tokenCallback;
@@ -90,9 +90,9 @@
90 90 * @return \Closure
91 91 */
92 92 public function __invoke(callable $handler)
93 93 {
94 - return function (RequestInterface $request, array $options) use ($handler) {
94 + return function (RequestInterface $request, array $options) use($handler) {
95 95 // Requests using "auth"="google_auth" will be authorized.
96 96 if (!isset($options['auth']) || $options['auth'] !== 'google_auth') {
97 97 return $handler($request, $options);
98 98 }
@@ -117,11 +117,11 @@
117 117 } else {
118 118 $headers = $this->fetcher->updateMetadata($request->getHeaders(), null, $this->httpHandler);
119 119 $request = Utils::modifyRequest($request, ['set_headers' => $headers]);
120 120 }
121 - if ($this->tokenCallback && $token = $this->fetcher->getLastReceivedToken()) {
122 - if (array_key_exists('access_token', $token)) {
123 - call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $token['access_token']);
121 + if ($this->tokenCallback && ($token = $this->fetcher->getLastReceivedToken())) {
122 + if (\array_key_exists('access_token', $token)) {
123 + \call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $token['access_token']);
124 124 }
125 125 }
126 126 return $request;
127 127 }