ErrorResponseException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getError() 0 3 1
A __construct() 0 10 1
1
<?php
2
/*
3
 * This file is part of JSON RPC Client.
4
 *
5
 * (c) Igor Lazarev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Strider2038\JsonRpcClient\Exception;
12
13
use Strider2038\JsonRpcClient\Response\ErrorObject;
14
15
/**
16
 * @author Igor Lazarev <[email protected]>
17
 */
18
class ErrorResponseException extends \Exception implements JsonRpcClientExceptionInterface
19
{
20
    private ErrorObject $error;
21
22
    public function __construct(ErrorObject $error)
23 9
    {
24
        $this->error = $error;
25 9
26
        parent::__construct(
27 9
            sprintf(
28 9
                'Server response has error: code %d, message "%s", data %s.',
29 9
                $error->getCode(),
30 9
                $error->getMessage(),
31 9
                json_encode($error->getData())
32 9
            )
33
        );
34
    }
35 9
36
    public function getError(): ErrorObject
37 1
    {
38
        return $this->error;
39 1
    }
40
}
41