Cache::request()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 10
cc 3
nc 3
nop 2
crap 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