Completed
Push — master ( 6578e4...b57e95 )
by Sandro
27s queued 17s
created

SuccessHttpStatusCode   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 3
1
<?php
2
/**
3
 * Sandro Keil (https://sandro-keil.de)
4
 *
5
 * @link      http://github.com/sandrokeil/arangodb-php-client for the canonical source repository
6
 * @copyright Copyright (c) 2018-2020 Sandro Keil
7
 * @license   http://github.com/sandrokeil/arangodb-php-client/blob/master/LICENSE.md New BSD License
8
 */
9
10
declare(strict_types=1);
11
12
namespace ArangoDb\Guard;
13
14
use ArangoDb\Exception\GuardErrorException;
15
use Fig\Http\Message\StatusCodeInterface;
16
use Psr\Http\Message\ResponseInterface;
17
18
final class SuccessHttpStatusCode implements Guard
19
{
20
    use ContentIdTrait;
21
22 8
    public function __invoke(ResponseInterface $response): void
23
    {
24 8
        $httpStatusCode = $response->getStatusCode();
25
26 8
        if ($httpStatusCode < StatusCodeInterface::STATUS_OK
27 8
            || $httpStatusCode > StatusCodeInterface::STATUS_MULTIPLE_CHOICES
28
        ) {
29 3
            throw GuardErrorException::with($response);
30
        }
31 8
    }
32
}
33