Completed
Pull Request — master (#5)
by Ryota
01:14
created

ApiErrorException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getApiMethodName() 0 4 1
A getArgs() 0 4 1
A newException() 0 7 1
1
<?php
2
namespace Polidog\Esa\Exception;
3
4
use GuzzleHttp\Exception\ClientException;
5
6
class ApiErrorException extends \RuntimeException
7
{
8
    /**
9
     * @var string
10
     */
11
    private $apiMethodName;
12
13
    /**
14
     * @var array
15
     */
16
    private $args;
17
18
    /**
19
     * @return string
20
     */
21
    public function getApiMethodName()
22
    {
23
        return $this->apiMethodName;
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function getArgs()
30
    {
31
        return $this->args;
32
    }
33
34
    /**
35
     * @param \Exception $e
36
     * @param            $name
37
     * @param array      $args
38
     * @return ApiErrorException
39
     */
40
    public static function newException(\Exception $e, $name, array $args)
41
    {
42
        $self = new self(sprintf("Api method error: %s", $name), $e->getCode(), $e);
43
        $self->apiMethodName = $name;
44
        $self->args = $args;
45
        return $self;
46
    }
47
48
}
49