| Conditions | 2 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function __invoke(callable $handler) |
||
| 20 | { |
||
| 21 | return function(RequestInterface $request, array $options) use ($handler) { |
||
| 22 | $key = sprintf('%s %s', $request->getMethod(), (string)$request->getUri()); |
||
| 23 | |||
| 24 | if (!isset($this->increments[$key])) { |
||
| 25 | $this->increments[$key] = 1; |
||
| 26 | } else { |
||
| 27 | ++$this->increments[$key]; |
||
| 28 | |||
| 29 | $key .= ' ('.$this->increments[$key].')'; |
||
| 30 | } |
||
| 31 | |||
| 32 | $this->stopwatch->start($key); |
||
| 33 | |||
| 34 | return $handler($request, $options)->then(function(ResponseInterface $response) use ($key) { |
||
| 35 | $this->stopwatch->stop($key); |
||
| 36 | |||
| 37 | return $response; |
||
| 38 | }); |
||
| 41 | } |