NetworkException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A with() 0 9 1
A getRequest() 0 3 1
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
namespace ArangoDb\Exception;
11
12
use Fig\Http\Message\StatusCodeInterface;
13
use Psr\Http\Client\ClientExceptionInterface;
14
use Psr\Http\Message\RequestInterface;
15
use Throwable;
16
17
final class NetworkException extends RuntimeException implements ClientExceptionInterface
18
{
19
    /**
20
     * @var RequestInterface
21
     */
22
    private $request;
23
24
    public static function with(RequestInterface $request, Throwable $previousException = null): self
25
    {
26
        $self = new self(
27
            'Response could no be evaluated.',
28
            StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR,
29
            $previousException
30
        );
31
        $self->request = $request;
32
        return $self;
33
    }
34
35
    public function getRequest(): RequestInterface
36
    {
37
        return $this->request;
38
    }
39
}
40