PluginProbe
Authorizer / 3.3.2
Authorizer v3.3.2
3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 2.9.6 All 126 releases
← All changes | vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php +10 -29 3.14.33.3.2 View file →
@@ -15,15 +15,10 @@
15 15 * limitations under the License.
16 16 */
17 17 namespace Google\Auth\HttpHandler;
18 18
19 -use Google\Auth\ApplicationDefaultCredentials;
20 -use GuzzleHttp\BodySummarizer;
21 19 use GuzzleHttp\Client;
22 20 use GuzzleHttp\ClientInterface;
23 -use GuzzleHttp\HandlerStack;
24 -use GuzzleHttp\Middleware;
25 -use Psr\Log\LoggerInterface;
26 21
27 22 class HttpHandlerFactory
28 23 {
29 24 /**
@@ -28,45 +23,31 @@
28 23 {
29 24 /**
30 25 * Builds out a default http handler for the installed version of guzzle.
31 26 *
32 - * @param ClientInterface|null $client
33 - * @param null|false|LoggerInterface $logger
34 - * @return Guzzle6HttpHandler|Guzzle7HttpHandler
27 + * @param ClientInterface $client
28 + * @return Guzzle5HttpHandler|Guzzle6HttpHandler|Guzzle7HttpHandler
35 29 * @throws \Exception
36 30 */
37 - public static function build(
38 - ?ClientInterface $client = null,
39 - null|false|LoggerInterface $logger = null,
40 - ) {
41 - if (is_null($client)) {
42 - $stack = null;
43 - if (class_exists(BodySummarizer::class)) {
44 - // double the # of characters before truncation by default
45 - $bodySummarizer = new BodySummarizer(240);
46 - $stack = HandlerStack::create();
47 - $stack->remove('http_errors');
48 - $stack->unshift(Middleware::httpErrors($bodySummarizer), 'http_errors');
49 - }
50 - $client = new Client(['handler' => $stack]);
51 - }
31 + public static function build(ClientInterface $client = null)
32 + {
33 + $client = $client ?: new Client();
52 34
53 - $logger = ($logger === false)
54 - ? null
55 - : $logger ?? ApplicationDefaultCredentials::getDefaultLogger();
56 -
57 35 $version = null;
58 36 if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
59 37 $version = ClientInterface::MAJOR_VERSION;
60 38 } elseif (defined('GuzzleHttp\ClientInterface::VERSION')) {
39 + /** @phpstan-ignore-next-line */
61 40 $version = (int) substr(ClientInterface::VERSION, 0, 1);
62 41 }
63 42
64 43 switch ($version) {
44 + case 5:
45 + return new Guzzle5HttpHandler($client);
65 46 case 6:
66 - return new Guzzle6HttpHandler($client, $logger);
47 + return new Guzzle6HttpHandler($client);
67 48 case 7:
68 - return new Guzzle7HttpHandler($client, $logger);
49 + return new Guzzle7HttpHandler($client);
69 50 default:
70 51 throw new \Exception('Version not supported');
71 52 }
72 53 }