Completed
Pull Request — master (#12)
by Romain
06:58
created

PaymentCredential::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 7
crap 1
1
<?php
2
namespace Kerox\Messenger\Model\Callback\Payment;
3
4
class PaymentCredential
5
{
6
7
    /**
8
     * @var string
9
     */
10
    protected $providerType;
11
12
    /**
13
     * @var string
14
     */
15
    protected $chargeId;
16
17
    /**
18
     * @var string
19
     */
20
    protected $tokenizedCard;
21
22
    /**
23
     * @var null|string
24
     */
25
    protected $tokenizedCvv;
26
27
    /**
28
     * @var null|string
29
     */
30
    protected $tokenExpiryMonth;
31
32
    /**
33
     * @var null|string
34
     */
35
    protected $tokenExpiryYear;
36
37
    /**
38
     * @var string
39
     */
40
    protected $fbPaymentId;
41
42
    /**
43
     * PaymentCredential constructor.
44
     *
45
     * @param string $providerType
46
     * @param string $chargeId
47
     * @param string $tokenizedCvv
48
     * @param string $tokenExpiryMonth
49
     * @param string $tokenExpiryYear
50
     * @param string $fbPaymentId
51
     */
52 5
    public function __construct(
53
        string $providerType,
54
        string $chargeId,
55
        string $tokenizedCard,
56
        string $tokenizedCvv,
57
        string $tokenExpiryMonth,
58
        string $tokenExpiryYear,
59
        string $fbPaymentId
60
    ) {
61 5
        $this->providerType = $providerType;
62 5
        $this->chargeId = $chargeId;
63 5
        $this->tokenizedCard = $tokenizedCard;
64 5
        $this->tokenizedCvv = $tokenizedCvv;
65 5
        $this->tokenExpiryMonth = $tokenExpiryMonth;
66 5
        $this->tokenExpiryYear = $tokenExpiryYear;
67 5
        $this->fbPaymentId = $fbPaymentId;
68 5
    }
69
70
    /**
71
     * @return string
72
     */
73 1
    public function getProviderType(): string
74
    {
75 1
        return $this->providerType;
76
    }
77
78
    /**
79
     * @return string
80
     */
81 1
    public function getChargeId(): string
82
    {
83 1
        return $this->chargeId;
84
    }
85
86
    /**
87
     * @return string
88
     */
89 1
    public function getTokenizedCard(): string
90
    {
91 1
        return $this->tokenizedCard;
92
    }
93
94
    /**
95
     * @return null|string
96
     */
97 1
    public function getTokenizedCvv()
98
    {
99 1
        return $this->tokenizedCvv;
100
    }
101
102
    /**
103
     * @return null|string
104
     */
105 1
    public function getTokenExpiryMonth()
106
    {
107 1
        return $this->tokenExpiryMonth;
108
    }
109
110
    /**
111
     * @return null|string
112
     */
113 1
    public function getTokenExpiryYear()
114
    {
115 1
        return $this->tokenExpiryYear;
116
    }
117
118
    /**
119
     * @return string
120
     */
121 1
    public function getFbPaymentId(): string
122
    {
123 1
        return $this->fbPaymentId;
124
    }
125
126
    /**
127
     * @param array $payload
128
     * @return static
129
     */
130 5
    public static function create(array $payload)
131
    {
132 5
        $tokenizedCard = $payload['tokenized_card'] ?? null;
133 5
        $tokenizedCvv = $payload['tokenized_cvv'] ?? null;
134 5
        $tokenExpiryMonth = $payload['token_expiry_month'] ?? null;
135 5
        $tokenExpiryYear = $payload['token_expiry_year'] ?? null;
136
137 5
        return new static($payload['provider_type'], $payload['charge_id'], $tokenizedCard, $tokenizedCvv, $tokenExpiryMonth, $tokenExpiryYear, $payload['fb_payment_id']);
138
    }
139
}
140