Conditions | 3 |
Paths | 3 |
Total Lines | 33 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function __invoke( |
||
24 | RequestInterface $request, |
||
25 | ResponseInterface $response, |
||
26 | callable $next = null |
||
27 | ): ResponseInterface { |
||
28 | parent::__invoke($request, $response); |
||
29 | |||
30 | $response = $next($request, $response); |
||
31 | |||
32 | // Only cache successful responses |
||
33 | if ($this->isResponseSuccessful($response)) { |
||
34 | $key = $this->getCacheKey($request); |
||
35 | |||
36 | if ($this->cache->delete($key)) { |
||
37 | $this->info( |
||
38 | "Item removed from cache successfully. [key: {key}, type: {type}]", |
||
39 | [ |
||
40 | 'type' => get_class($this->cache), |
||
41 | 'key' => $key |
||
42 | ] |
||
43 | ); |
||
44 | } else { |
||
45 | $this->info( |
||
46 | "Item not removed from cache. [key: {key}, type: {type}]", |
||
47 | [ |
||
48 | 'type' => get_class($this->cache), |
||
49 | 'key' => $key |
||
50 | ] |
||
51 | ); |
||
52 | } |
||
53 | } |
||
54 | return $response; |
||
55 | } |
||
56 | } |
||
57 |