ClientException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 57
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A newException() 0 9 1
A getMethod() 0 4 1
A getPath() 0 4 1
A getParams() 0 4 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