Completed
Push — master ( 3ee5ff...5084e8 )
by Joachim
12:38
created

Config::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 18
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 Method

Rating   Name   Duplication   Size   Complexity  
A Config::getPayload() 0 16 1
1
<?php
2
namespace Loevgaard\AltaPay\Payload\PaymentRequest;
3
4
use Assert\Assert;
5
use Loevgaard\AltaPay\Payload\Payload;
6
7
class Config extends Payload implements ConfigInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $callbackForm;
13
14
    /**
15
     * @var string
16
     */
17
    protected $callbackOk;
18
19
    /**
20
     * @var string
21
     */
22
    protected $callbackFail;
23
24
    /**
25
     * @var string
26
     */
27
    protected $callbackRedirect;
28
29
    /**
30
     * @var string
31
     */
32
    protected $callbackOpen;
33
34
    /**
35
     * @var string
36
     */
37
    protected $callbackNotification;
38
39
    /**
40
     * @var string|null
41
     */
42
    protected $callbackVerifyOrder;
43 6
44
    public function getPayload() : array
45
    {
46
        $payload = [
47
            'callback_form' => $this->callbackForm,
48
            'callback_ok' => $this->callbackOk,
49
            'callback_fail' => $this->callbackFail,
50
            'callback_redirect' => $this->callbackRedirect,
51
            'callback_open' => $this->callbackOpen,
52
            'callback_notification' => $this->callbackNotification,
53 6
            'callback_verify_order' => $this->callbackVerifyOrder,
54 6
        ];
55 6
56 6
        $this->validate();
57 6
58 6
        return static::simplePayload($payload);
59 6
    }
60 6
61
    public function validate()
62 6
    {
63
        Assert::thatNullOr($this->callbackForm)->string();
64
        Assert::thatNullOr($this->callbackOk)->string();
65 6
        Assert::thatNullOr($this->callbackFail)->string();
66 6
        Assert::thatNullOr($this->callbackRedirect)->string();
67 6
        Assert::thatNullOr($this->callbackOpen)->string();
68 6
        Assert::thatNullOr($this->callbackNotification)->string();
69 6
        Assert::thatNullOr($this->callbackVerifyOrder)->string();
70 6
    }
71 6
72 4
    /**
73
     * @return string
74 6
     */
75
    public function getCallbackForm() : ?string
76
    {
77
        return $this->callbackForm;
78
    }
79
80 6
    /**
81
     * @param string $callbackForm
82 6
     * @return Config
83
     */
84
    public function setCallbackForm(string $callbackForm) : self
85
    {
86
        $this->callbackForm = $callbackForm;
87
        return $this;
88
    }
89 6
90
    /**
91 6
     * @return string
92 6
     */
93 6
    public function getCallbackOk() : ?string
94
    {
95
        return $this->callbackOk;
96
    }
97
98
    /**
99 6
     * @param string $callbackOk
100
     * @return Config
101 6
     */
102
    public function setCallbackOk(string $callbackOk) : self
103
    {
104
        $this->callbackOk = $callbackOk;
105
        return $this;
106
    }
107
108 6
    /**
109
     * @return string
110 6
     */
111 6
    public function getCallbackFail() : ?string
112 6
    {
113
        return $this->callbackFail;
114
    }
115
116
    /**
117
     * @param string $callbackFail
118 6
     * @return Config
119
     */
120 6
    public function setCallbackFail(string $callbackFail) : self
121
    {
122
        $this->callbackFail = $callbackFail;
123
        return $this;
124
    }
125
126
    /**
127 6
     * @return string
128
     */
129 6
    public function getCallbackRedirect() : ?string
130 6
    {
131 6
        return $this->callbackRedirect;
132
    }
133
134
    /**
135
     * @param string $callbackRedirect
136
     * @return Config
137 6
     */
138
    public function setCallbackRedirect(string $callbackRedirect) : self
139 6
    {
140
        $this->callbackRedirect = $callbackRedirect;
141
        return $this;
142
    }
143
144
    /**
145
     * @return string
146 6
     */
147
    public function getCallbackOpen() : ?string
148 6
    {
149 6
        return $this->callbackOpen;
150 6
    }
151
152
    /**
153
     * @param string $callbackOpen
154
     * @return Config
155
     */
156 6
    public function setCallbackOpen(string $callbackOpen) : self
157
    {
158 6
        $this->callbackOpen = $callbackOpen;
159
        return $this;
160
    }
161
162
    /**
163
     * @return string
164
     */
165 6
    public function getCallbackNotification() : ?string
166
    {
167 6
        return $this->callbackNotification;
168 6
    }
169 6
170
    /**
171
     * @param string $callbackNotification
172
     * @return Config
173
     */
174
    public function setCallbackNotification(string $callbackNotification) : self
175 6
    {
176
        $this->callbackNotification = $callbackNotification;
177 6
        return $this;
178
    }
179
180
    /**
181
     * @return string
182
     */
183
    public function getCallbackVerifyOrder() : ?string
184 6
    {
185
        return $this->callbackVerifyOrder;
186 6
    }
187 6
188 6
    /**
189
     * @param string $callbackVerifyOrder
190
     * @return Config
191
     */
192
    public function setCallbackVerifyOrder(string $callbackVerifyOrder) : self
193
    {
194 6
        $this->callbackVerifyOrder = $callbackVerifyOrder;
195
        return $this;
196 6
    }
197
}
198