1 | <?php |
||
18 | class ProfilePlugin implements Plugin |
||
19 | { |
||
20 | /** |
||
21 | * @var Plugin |
||
22 | */ |
||
23 | private $plugin; |
||
24 | |||
25 | /** |
||
26 | * @var Collector |
||
27 | */ |
||
28 | private $collector; |
||
29 | |||
30 | /** |
||
31 | * @var Formatter |
||
32 | */ |
||
33 | private $formatter; |
||
34 | |||
35 | /** |
||
36 | * @param Plugin $plugin |
||
37 | * @param Collector $collector |
||
38 | * @param Formatter $formatter |
||
39 | */ |
||
40 | 10 | public function __construct(Plugin $plugin, Collector $collector, Formatter $formatter) |
|
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | 8 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
89 | |||
90 | /** |
||
91 | * @param RequestInterface $request |
||
92 | * @param Profile $profile |
||
93 | * @param Exception $exception |
||
94 | * @param Stack $stack |
||
95 | */ |
||
96 | 2 | private function onException( |
|
106 | |||
107 | /** |
||
108 | * @param RequestInterface $request |
||
109 | * @param Profile $profile |
||
110 | */ |
||
111 | 7 | private function onOutgoingRequest(RequestInterface $request, Profile $profile) |
|
115 | |||
116 | /** |
||
117 | * @param ResponseInterface $response |
||
118 | * @param Profile $profile |
||
119 | * @param RequestInterface $request |
||
120 | * @param Stack $stack |
||
121 | */ |
||
122 | 6 | private function onOutgoingResponse(ResponseInterface $response, Profile $profile, RequestInterface $request, Stack $stack = null) |
|
127 | |||
128 | /** |
||
129 | * Collect request information when not already done by the HTTP client. This happens when using the CachePlugin |
||
130 | * and the cache is hit without re-validation. |
||
131 | * |
||
132 | * @param RequestInterface $request |
||
133 | * @param Stack|null $stack |
||
134 | */ |
||
135 | 8 | private function collectRequestInformation(RequestInterface $request, Stack $stack = null) |
|
156 | } |
||
157 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: