Cache   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A request() 0 14 3
1
<?php
2
3
namespace hamburgscleanest\GuzzleAdvancedThrottle\Cache\Strategies;
4
5
use GuzzleHttp\Promise\FulfilledPromise;
6
use GuzzleHttp\Promise\PromiseInterface;
7
use Psr\Http\Message\RequestInterface;
8
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
9
10
class Cache extends Cacheable
11
{
12 13
    public function request(RequestInterface $request, callable $handler): PromiseInterface
13
    {
14
        try
15
        {
16 13
            return parent::request($request, $handler);
17
        }
18 13
        catch (TooManyRequestsHttpException $tooManyRequestsHttpException)
19
        {
20 13
            $response = $this->_getResponse($request);
21 13
            if ($response !== null) {
22 7
                return new FulfilledPromise($response);
23
            }
24
25 8
            throw $tooManyRequestsHttpException;
26
        }
27
    }
28
}
29