Passed
Pull Request — master (#109)
by Romain
03:30
created

PaymentCredential::getTokenizedCard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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