ClientException::newException()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Esa\Exception;
6
7
class ClientException extends \RuntimeException
8
{
9
    /**
10
     * @var string
11
     */
12
    private $method;
13
14
    /**
15
     * @var string
16
     */
17
    private $path;
18
19
    /**
20
     * @var array
21
     */
22
    private $params;
23
24
    /**
25
     * @return string
26
     */
27
    public function getMethod()
28
    {
29
        return $this->method;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getPath()
36
    {
37
        return $this->path;
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function getParams()
44
    {
45
        return $this->params;
46
    }
47
48
    /**
49
     * @param $method
50
     * @param $path
51
     *
52
     * @return ClientException
53
     */
54 1
    public static function newException(\Exception $e, $method, $path, array $params)
55
    {
56 1
        $self = new self(sprintf('Api method error: %s : %s', $method, $path), $e->getCode(), $e);
57 1
        $self->method = $method;
58 1
        $self->path = $path;
59 1
        $self->params = $params;
60
61 1
        return $self;
62
    }
63
}
64