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

ErrorResponseException::getError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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