| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace ElfSundae; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Closure; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use ReflectionClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use GuzzleHttp\Client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use BadMethodCallException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Illuminate\Support\Arr; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Illuminate\Support\Str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use GuzzleHttp\RequestOptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Psr\Http\Message\UriInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @method $this get(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @method $this head(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @method $this post(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @method $this put(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @method $this patch(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @method $this delete(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @method $this options(string|UriInterface $uri = '', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @method int getStatusCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @method string getReasonPhrase() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @method string getProtocolVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @method array getHeaders() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @method bool hasHeader(string $header) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @method array getHeader(string $header) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * @method string getHeaderLine(string $header) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * @method \Psr\Http\Message\StreamInterface getBody() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @method $this allowRedirects(bool|array $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * @method $this auth(array|string|null $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @method $this body(mixed $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * @method $this cert(string|array $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @method $this cookies(bool|\GuzzleHttp\Cookie\CookieJarInterface $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * @method $this connectTimeout(float $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @method $this debug(bool|resource $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @method $this decodeContent(bool $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * @method $this delay(int|float $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * @method $this expect(bool|int $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * @method $this formParams(array $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @method $this headers(array $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  * @method $this httpErrors(bool $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  * @method $this json(mixed $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  * @method $this multipart(array $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  * @method $this onHeaders(callable $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  * @method $this onStats(callable $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  * @method $this progress(callable $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  * @method $this proxy(string|array $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  * @method $this query(array|string $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  * @method $this sink(string|resource|\Psr\Http\Message\StreamInterface $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  * @method $this sslKey(array|string $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  * @method $this stream(bool $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  * @method $this verify(bool|string $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  * @method $this timeout(float $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  * @method $this readTimeout(float $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  * @method $this version(float|string $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  * @method $this forceIpResolve(string $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  * @see http://docs.guzzlephp.org/en/stable/request-options.html Request Options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | class HttpClient | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * The default request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     protected static $defaultOptions = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         'connect_timeout' => 5, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         'timeout' => 20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         'http_errors' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * The Guzzle client. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @var \GuzzleHttp\Client | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     protected $client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * The request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     protected $options = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * The Guzzle response. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @var \GuzzleHttp\Psr7\Response | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     protected $response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * Indicate whether to catch Guzzle exceptions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     protected $catchExceptions = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * Get the default request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 | 28 |  |     public static function defaultOptions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 28 |  |         return static::$defaultOptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * Set the default request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * @param  array  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 29 |  |     public static function setDefaultOptions(array $options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 29 |  |         static::$defaultOptions = $options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 29 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * Create a new http client instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * @param  array|string|\Psr\Http\Message\UriInterface  $options  base URI or any request options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * @throws \InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 28 |  |     public function __construct($options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 28 |  |         if (is_string($options) || $options instanceof UriInterface) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 1 |  |             $options = ['base_uri' => $options]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 28 |  |         } elseif (! is_array($options)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 1 |  |             throw new InvalidArgumentException('Options must be a string, UriInterface, or an array'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 27 |  |         $this->client = new Client( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 27 |  |             array_replace_recursive(static::defaultOptions(), $options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 27 |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 27 |  |         $this->options = $this->client->getConfig(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 27 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * Get the Guzzle client instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * @return \GuzzleHttp\Client | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 4 |  |     public function getClient() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 | 4 |  |         return $this->client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * Get whether to catch Guzzle exceptions or not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 1 |  |     public function areExceptionsCaught() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 1 |  |         return $this->catchExceptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * Set whether to catch Guzzle exceptions or not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @param  bool  $catch | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 | 2 |  |     public function catchExceptions($catch) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 2 |  |         $this->catchExceptions = (bool) $catch; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 | 2 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      * Get the request options using "dot" notation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * @param  string|null  $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 12 |  |     public function getOption($key = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 12 |  |         return Arr::get($this->options, $key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * Set the request options using "dot" notation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      * @param  string|array  $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      * @param  mixed  $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 9 |  |     public function option($key, $value = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 | 9 |  |         $keys = is_array($key) ? $key : [$key => $value]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 9 |  |         foreach ($keys as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 9 |  |             Arr::set($this->options, $key, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 9 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 9 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * Merge the given options to the request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @param  array  ...$options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 | 1 |  |     public function mergeOptions(array ...$options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 1 |  |         $this->options = array_replace_recursive($this->options, ...$options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 | 1 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |      * Remove one or many request options using "dot" notation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |      * @param  array|string  $keys | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 | 2 |  |     public function removeOption($keys) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 | 2 |  |         Arr::forget($this->options, is_array($keys) ? $keys : func_get_args()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 | 2 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * Set a request header. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      * @param  string  $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * @param  mixed  $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * @return $this | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 241 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 242 | 6 |  |     public function header($name, $value) | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 244 | 6 |  |         return $this->option('headers.'.$name, $value); | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * Set the request accept type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      * @param  string  $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 | 3 |  |     public function accept($type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 | 3 |  |         return $this->header('Accept', $type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |      * Set the request accept type to "application/json". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 | 1 |  |     public function acceptJson() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 | 1 |  |         return $this->accept('application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |      * Set user agent for the request. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |      * @param  string  $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 | 1 |  |     public function userAgent($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 | 1 |  |         return $this->header('User-Agent', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      * Set the request content type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |      * @param  string  $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 | 1 |  |     public function contentType($type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 | 1 |  |         return $this->header('Content-Type', $type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |      * Specify where the body of the response will be saved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |      * Set the "sink" option. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |      * @param  string|resource|\Psr\Http\Message\StreamInterface  $dest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 | 1 |  |     public function saveTo($dest) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 | 1 |  |         return $this->removeOption('save_to')->option('sink', $dest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |      * Get the Guzzle response instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * @return \GuzzleHttp\Psr7\Response|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 | 3 |  |     public function getResponse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 | 3 |  |         return $this->response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |      * Get data from the response. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |      * @param  string|\Closure  $callback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |      * @param  mixed  $parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |      * @param  mixed  $default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 | 6 |  |     public function getResponseData($callback, $parameters = [], $default = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 | 6 |  |         if ($this->response) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |             return $callback instanceof Closure | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 | 6 |  |                 ? $callback($this->response, ...(array) $parameters) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 | 6 |  |                 : $this->response->$callback(...(array) $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 | 1 |  |         return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |      * Get the response content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 | 4 |  |     public function getContent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 | 4 |  |         return (string) $this->getBody(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |      * Get the JSON-decoded response content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |      * @param  bool  $assoc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 | 2 |  |     public function getJson($assoc = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 | 2 |  |         return json_decode($this->getContent(), $assoc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |      * Make request to a URI. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      * @param  string|\Psr\Http\Message\UriInterface  $uri | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |      * @param  array  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 | 11 |  |     public function request($uri = '', $method = 'GET', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 | 11 |  |         $this->response = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 | 11 |  |         $method = strtoupper($method); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 | 11 |  |         $options = array_replace_recursive($this->options, $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 | 11 |  |             $this->response = $this->client->request($method, $uri, $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 | 11 |  |         } catch (Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 | 1 |  |             if (! $this->catchExceptions) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 | 1 |  |                 throw $e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 | 11 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |      * Make request to a URI, expecting JSON content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |      * @param  string|\Psr\Http\Message\UriInterface  $uri | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |      * @param  array  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 | 2 |  |     public function requestJson($uri = '', $method = 'GET', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 | 2 |  |         $options = $this->addAcceptableJsonType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 | 2 |  |             array_replace_recursive($this->options, $options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 | 2 |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 | 2 |  |         return $this->request($uri, $method, $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |      * Add JSON type to the "Accept" header for the request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |      * @param  array  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 | 2 |  |     protected function addAcceptableJsonType(array $options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 | 2 |  |         $accept = Arr::get($options, 'headers.Accept', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 | 2 |  |         if (! Str::contains($accept, ['/json', '+json'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 | 2 |  |             $accept = rtrim('application/json,'.$accept, ','); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 | 2 |  |             Arr::set($options, 'headers.Accept', $accept); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 | 2 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 | 2 |  |         return $options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      * Request the URI and return the response content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |      * @param  string|\Psr\Http\Message\UriInterface  $uri | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |      * @param  array  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 | 1 |  |     public function fetchContent($uri = '', $method = 'GET', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 | 1 |  |         return $this->request($uri, $method, $options)->getContent(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |      * Request the URI and return the JSON-decoded response content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |      * @param  string|\Psr\Http\Message\UriInterface  $uri | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |      * @param  array  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 | 1 |  |     public function fetchJson($uri = '', $method = 'GET', array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 | 1 |  |         return $this->requestJson($uri, $method, $options)->getJson(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |      * Get all allowed magic request methods. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 | 9 |  |     protected function getMagicRequestMethods() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 | 9 |  |             'get', 'head', 'post', 'put', 'patch', 'delete', 'options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 | 9 |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |      * Get parameters for $this->request() from the magic request call. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |      * @param  array  $parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 | 2 |  |     protected function getRequestParameters($method, array $parameters) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 | 2 |  |         if (empty($parameters)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 | 1 |  |             $parameters = ['', $method]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 | 1 |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 | 2 |  |             array_splice($parameters, 1, 0, $method); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 | 2 |  |         return $parameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |      * Get all allowed magic response methods. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 | 7 |  |     protected function getMagicResponseMethods() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 | 7 |  |             'getStatusCode', 'getReasonPhrase', 'getProtocolVersion', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 | 7 |  |             'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine', 'getBody', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 | 7 |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |      * Get all allowed magic option methods. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 | 2 |  |     protected function getMagicOptionMethods() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 | 2 |  |         static $optionMethods = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 | 2 |  |         if (is_null($optionMethods)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 | 1 |  |             $reflector = new ReflectionClass(RequestOptions::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 | 1 |  |             $optionMethods = array_map( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 | 1 |  |                 [Str::class, 'camel'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 | 1 |  |                 array_values($reflector->getConstants()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 | 1 |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 | 2 |  |         return $optionMethods; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |      * Get the option name for the given magic option method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 | 2 |  |     protected function getOptionNameForMethod($method) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 | 2 |  |         if (in_array($method, $this->getMagicOptionMethods())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 | 1 |  |             return Str::snake($method); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |      * Handle magic method to send request, get response data, or set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |      * request options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |      * @param  string  $method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |      * @param  array  $parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |      * @throws \InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |      * @throws \BadMethodCallException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 | 9 |  |     public function __call($method, $parameters) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 | 9 |  |         if (in_array($method, $this->getMagicRequestMethods())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 | 2 |  |             return $this->request(...$this->getRequestParameters($method, $parameters)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 | 7 |  |         if (in_array($method, $this->getMagicResponseMethods())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 | 5 |  |             return $this->getResponseData($method, $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 | 2 |  |         if ($option = $this->getOptionNameForMethod($method)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 | 1 |  |             if (empty($parameters)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 | 1 |  |                 throw new InvalidArgumentException("Method [$method] needs one argument."); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 | 1 |  |             return $this->option($option, $parameters[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 | 1 |  |         throw new BadMethodCallException("Method [$method] does not exist."); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 546 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 547 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: