Passed
Push — master ( 670d61...49fd8e )
by Igor
02:16
created

ErrorResponseException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getError() 0 3 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 ResponseException
19
{
20
    /** @var ErrorObject */
21
    private $error;
22
23 5
    public function __construct(ErrorObject $error)
24
    {
25 5
        $this->error = $error;
26
27 5
        parent::__construct(
28 5
            sprintf(
29 5
                'Server response has error: code %d, message "%s", data %s.',
30 5
                $error->code,
31 5
                $error->message,
32 5
                json_encode($error->data)
33
            )
34
        );
35 5
    }
36
37 1
    public function getError(): ErrorObject
38
    {
39 1
        return $this->error;
40
    }
41
}
42