1 | <?php |
||
22 | class ProfileClient implements HttpClient, HttpAsyncClient |
||
23 | { |
||
24 | /** |
||
25 | * @var HttpClient|HttpAsyncClient |
||
26 | */ |
||
27 | private $client; |
||
28 | |||
29 | /** |
||
30 | * @var Collector |
||
31 | */ |
||
32 | private $collector; |
||
33 | |||
34 | /** |
||
35 | * @var Formatter |
||
36 | */ |
||
37 | private $formatter; |
||
38 | |||
39 | /** |
||
40 | * @var Stopwatch |
||
41 | */ |
||
42 | private $stopwatch; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | private $eventNames = []; |
||
48 | |||
49 | /** |
||
50 | * @param HttpClient|HttpAsyncClient $client The client to profile. Client must implement both HttpClient and |
||
51 | * HttpAsyncClient interfaces. |
||
52 | * @param Collector $collector |
||
53 | * @param Formatter $formatter |
||
54 | * @param Stopwatch $stopwatch |
||
55 | */ |
||
56 | 6 | public function __construct($client, Collector $collector, Formatter $formatter, Stopwatch $stopwatch) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function sendAsyncRequest(RequestInterface $request) |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function sendRequest(RequestInterface $request) |
||
120 | |||
121 | /** |
||
122 | * @param RequestInterface $request |
||
123 | * @param Stack|null $stack |
||
124 | */ |
||
125 | private function collectRequestInformations(RequestInterface $request, Stack $stack = null) |
||
137 | |||
138 | /** |
||
139 | * @param ResponseInterface $response |
||
140 | * @param StopwatchEvent $event |
||
141 | * @param Stack|null $stack |
||
142 | */ |
||
143 | private function collectResponseInformations(ResponseInterface $response, StopwatchEvent $event, Stack $stack = null) |
||
153 | |||
154 | /** |
||
155 | * @param \Exception $exception |
||
156 | * @param StopwatchEvent $event |
||
157 | * @param Stack|null $stack |
||
158 | */ |
||
159 | private function collectExceptionInformations(\Exception $exception, StopwatchEvent $event, Stack $stack = null) |
||
172 | |||
173 | /** |
||
174 | * Generates the event name. |
||
175 | * |
||
176 | * @param RequestInterface $request |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | private function getStopwatchEventName(RequestInterface $request) |
||
192 | } |
||
193 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.