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

SuccessHttpStatusCode::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

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