ApiException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A getErrorResponse() 0 4 1
1
<?php
2
namespace CultureKings\Afterpay\Exception;
3
4
use CultureKings\Afterpay\Model\ErrorResponse;
5
use \Exception;
6
use \RuntimeException;
7
8
/**
9
 * Class ApiException
10
 * @package CultureKings\Afterpay\Exception
11
 */
12
class ApiException extends RuntimeException
13
{
14
    /**
15
     * @var ErrorResponse
16
     */
17
    protected $errorResponse;
18
19
    /**
20
     * ApiException constructor.
21
     *
22
     * @param ErrorResponse    $errorResponse
23
     * @param Exception|string $message
24
     * @param int              $code
25
     * @param Exception|null   $previous
26
     */
27
    public function __construct(ErrorResponse $errorResponse, $message = "", $code = 0, Exception $previous = null)
28
    {
29
        $this->errorResponse = $errorResponse;
30
31
        //allow minimal construction
32
        if ($message instanceof Exception) {
33
            $previous = $message;
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $previous. This often makes code more readable.
Loading history...
34
            $message = $previous->getMessage();
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $message. This often makes code more readable.
Loading history...
35
        }
36
37
        parent::__construct($message, $code, $previous);
38
    }
39
40
    /**
41
     * @return ErrorResponse
42
     */
43
    public function getErrorResponse()
44
    {
45
        return $this->errorResponse;
46
    }
47
}
48