RequestFailedException::getRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
declare(strict_types=1);
10
11
namespace ArangoDb\Exception;
12
13
use Fig\Http\Message\StatusCodeInterface;
14
use Psr\Http\Client\RequestExceptionInterface;
15
use Psr\Http\Message\RequestInterface;
16
use Throwable;
17
18
final class RequestFailedException extends RuntimeException implements RequestExceptionInterface
19
{
20
    /**
21
     * @var RequestInterface
22
     */
23
    private $request;
24
25
    public static function ofRequest(RequestInterface $request, Throwable $previousException = null): self
26
    {
27
        $self = new self(
28
            sprintf('Request to "%s" failed.', $request->getUri()),
29
            StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR,
30
            $previousException
31
        );
32
        $self->request = $request;
33
        return $self;
34
    }
35
36
    public function getRequest(): RequestInterface
37
    {
38
        return $this->request;
39
    }
40
}
41