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

ApiErrorException::newException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
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