Completed
Pull Request — master (#60)
by ARCANEDEV
08:31
created

CardException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
dl 0
loc 62
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeclineCode() 0 4 1
A setDeclineCode() 0 6 1
A __construct() 0 21 2
1
<?php namespace Arcanedev\Stripe\Exceptions;
2
3
/**
4
 * Class     CardException
5
 *
6
 * @package  Arcanedev\Stripe\Exceptions
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
class CardException extends StripeException
10
{
11
    /* ------------------------------------------------------------------------------------------------
12
     |  Properties
13
     | ------------------------------------------------------------------------------------------------
14
     */
15
    protected $declineCode;
16
17
    /* ------------------------------------------------------------------------------------------------
18
     |  Constructor
19
     | ------------------------------------------------------------------------------------------------
20
     */
21
    /**
22
     * CardException constructor.
23
     *
24
     * @param  string       $message
25
     * @param  int          $code
26
     * @param  string|null  $type
27
     * @param  string|null  $stripeCode
28
     * @param  string|null  $httpBody
29
     * @param  array        $jsonBody
30
     * @param  array        $params
31
     * @param  array        $headers
32
     */
33 8
    public function __construct(
34
        $message,
35
        $code,
36
        $type,
37
        $stripeCode,
38
        $httpBody,
39
        array $jsonBody,
40
        array $params = [],
41
        array $headers = []
42
    ) {
43 8
        parent::__construct(
44 8
            $message, $code, $type, $stripeCode, $httpBody, $jsonBody, $params, $headers
45
        );
46
47
        // This one is not like the others because it was added later and we're trying to do our best
48
        // not to change the public interface of this class' constructor.
49
        // We should consider changing its implementation on the next major version bump of this library.
50 8
        $this->setDeclineCode(
51 8
            isset($jsonBody['error']['decline_code']) ? $jsonBody['error']['decline_code'] : null
52
        );
53 8
    }
54
55
    /* ------------------------------------------------------------------------------------------------
56
     |  Getters & Setters
57
     | ------------------------------------------------------------------------------------------------
58
     */
59
    public function getDeclineCode()
60
    {
61
        return $this->declineCode;
62
    }
63
64 8
    private function setDeclineCode($declineCode)
65
    {
66 8
        $this->declineCode = $declineCode;
67
68 8
        return $this;
69
    }
70
}
71