1 | <?php |
||
16 | class ClientBridge implements HttpClientInterface |
||
17 | { |
||
18 | protected $phantomJsClient = null; |
||
19 | |||
20 | /** @var array Default request options */ |
||
21 | private $config; |
||
22 | |||
23 | /** |
||
24 | * ClientBridge constructor. |
||
25 | * |
||
26 | * @param array $config |
||
27 | */ |
||
28 | 1 | public function __construct(array $config = []) |
|
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | public function request(string $method, string $url, array $options = []): ResponseInterface |
||
52 | |||
53 | /** |
||
54 | * @inheritdoc |
||
55 | */ |
||
56 | public function requestAsync($method, $uri = '', array $options = []) |
||
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | public function send(RequestInterface $request, array $options = []) |
||
66 | |||
67 | /** |
||
68 | * @inheritdoc |
||
69 | */ |
||
70 | public function sendAsync(RequestInterface $request, array $options = []) |
||
73 | |||
74 | /** |
||
75 | * @inheritdoc |
||
76 | */ |
||
77 | public function stream($responses, float $timeout = null): ResponseStreamInterface |
||
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | public function getConfig($option = null) |
||
90 | |||
91 | /** |
||
92 | * Configures the default options for a client. |
||
93 | * |
||
94 | * @param array $config |
||
95 | */ |
||
96 | 1 | protected function configureDefaults(array $config) |
|
102 | |||
103 | /** |
||
104 | * @return array |
||
105 | */ |
||
106 | 1 | protected function getConfigDefaults() |
|
112 | |||
113 | /** |
||
114 | * @param $option |
||
115 | * @param $value |
||
116 | * |
||
117 | * @return mixed |
||
118 | */ |
||
119 | public function setConfig($option, $value) |
||
123 | |||
124 | /** |
||
125 | * @param PhantomJsBaseClient $client |
||
126 | * @param $method |
||
127 | * @param string $uri |
||
128 | * @param array $parameters |
||
129 | * |
||
130 | * @return RequestInterface |
||
131 | */ |
||
132 | protected function createRequest($client, $method, $uri = '', array $parameters = []) |
||
154 | |||
155 | /** |
||
156 | * @param RequestInterface $request |
||
157 | * |
||
158 | * @return RequestInterface |
||
159 | */ |
||
160 | protected function applyConfig($request) |
||
169 | |||
170 | |||
171 | /** |
||
172 | * @return PhantomJsBaseClient|null |
||
173 | */ |
||
174 | protected function getPhantomJsClient() |
||
183 | } |
||
184 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: