@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | function fillProperty(string $property, $value) |
30 | 30 | { |
31 | 31 | $property = lcfirst(str_replace('_', '', ucwords($property, '_'))); |
32 | - if(property_exists(__CLASS__, $property)) |
|
32 | + if (property_exists(__CLASS__, $property)) |
|
33 | 33 | { |
34 | 34 | $method = sprintf('set%s', ucfirst($property)); |
35 | 35 | $this->{$method}($value); |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $reflection = new \ReflectionClass(__CLASS__); |
45 | 45 | $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); |
46 | 46 | $data = []; |
47 | - foreach($properties as $property){ |
|
47 | + foreach ($properties as $property) { |
|
48 | 48 | $prop_name = $property->getName(); |
49 | 49 | $method = sprintf('get%s', ucfirst($prop_name)); |
50 | 50 | $form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); |
51 | - if($reflection->hasMethod($method)){ |
|
51 | + if ($reflection->hasMethod($method)) { |
|
52 | 52 | $data[$form_name] = $this->{$method}(); |
53 | 53 | } |
54 | 54 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | static function getEntrypoint(): string |
27 | 27 | { |
28 | - return self::ENTRYPOINT.self::VERSION.'/'; |
|
28 | + return self::ENTRYPOINT . self::VERSION . '/'; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param AccessToken $accessToken |
17 | 17 | * @return CheckoutInterface |
18 | 18 | */ |
19 | - public function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface; |
|
19 | + public function create(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Retrieve a checkout from sumup.com server |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param AccessToken $accessToken |
26 | 26 | * @return CheckoutInterface |
27 | 27 | */ |
28 | - public function get(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface; |
|
28 | + public function get(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Complete a checkout |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param AccessToken $accessToken |
35 | 35 | * @return CheckoutInterface |
36 | 36 | */ |
37 | - public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface; |
|
37 | + public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Generate body to request a new checkout. |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @inheritDoc |
99 | 99 | */ |
100 | - public function getId():? string { |
|
100 | + public function getId(): ? string { |
|
101 | 101 | return $this->id; |
102 | 102 | } |
103 | 103 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * @inheritDoc |
114 | 114 | */ |
115 | - public function getStatus():? string { |
|
115 | + public function getStatus(): ? string { |
|
116 | 116 | return $this->status; |
117 | 117 | } |
118 | 118 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * @inheritDoc |
129 | 129 | */ |
130 | - public function getAmount():? float { |
|
130 | + public function getAmount(): ? float { |
|
131 | 131 | return $this->amount; |
132 | 132 | } |
133 | 133 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @inheritDoc |
144 | 144 | */ |
145 | - public function getCurrency():? string { |
|
145 | + public function getCurrency(): ? string { |
|
146 | 146 | return $this->currency; |
147 | 147 | } |
148 | 148 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @inheritDoc |
159 | 159 | */ |
160 | - public function getPayToEmail():? string { |
|
160 | + public function getPayToEmail(): ? string { |
|
161 | 161 | return $this->payToEmail; |
162 | 162 | } |
163 | 163 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @inheritDoc |
174 | 174 | */ |
175 | - public function getCheckoutReference():? string { |
|
175 | + public function getCheckoutReference(): ? string { |
|
176 | 176 | return $this->reference; |
177 | 177 | } |
178 | 178 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | /** |
188 | 188 | * @inheritDoc |
189 | 189 | */ |
190 | - public function getDescription():? string { |
|
190 | + public function getDescription(): ? string { |
|
191 | 191 | return $this->description; |
192 | 192 | } |
193 | 193 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @inheritDoc |
204 | 204 | */ |
205 | - public function getFeeAmount():? float { |
|
205 | + public function getFeeAmount(): ? float { |
|
206 | 206 | return $this->feeAmount; |
207 | 207 | } |
208 | 208 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * @inheritDoc |
219 | 219 | */ |
220 | - public function getPayFromEmail():? string { |
|
220 | + public function getPayFromEmail(): ? string { |
|
221 | 221 | return $this->payFromEmail; |
222 | 222 | } |
223 | 223 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * @inheritDoc |
234 | 234 | */ |
235 | - public function getRedirectUrl():? string { |
|
235 | + public function getRedirectUrl(): ? string { |
|
236 | 236 | return $this->redirectUrl; |
237 | 237 | } |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 | |
247 | - function getValidUntil():? string { |
|
247 | + function getValidUntil(): ? string { |
|
248 | 248 | return $this->validUntil; |
249 | 249 | } |
250 | 250 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | return $this; |
254 | 254 | } |
255 | 255 | |
256 | - function getTransactionCode():? string { |
|
256 | + function getTransactionCode(): ? string { |
|
257 | 257 | return $this->transactionCode; |
258 | 258 | } |
259 | 259 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | return $this; |
263 | 263 | } |
264 | 264 | |
265 | - function getTransactionId():? string { |
|
265 | + function getTransactionId(): ? string { |
|
266 | 266 | return $this->transactionId; |
267 | 267 | } |
268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | return $this; |
272 | 272 | } |
273 | 273 | |
274 | - function getTransactions():? array { |
|
274 | + function getTransactions(): ? array { |
|
275 | 275 | // return $this->transactions; |
276 | 276 | //TODO remember myself whats is it. |
277 | 277 | return []; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | return $this; |
284 | 284 | } |
285 | 285 | |
286 | - function getToken():? string { |
|
286 | + function getToken(): ? string { |
|
287 | 287 | return $this->token; |
288 | 288 | } |
289 | 289 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | /** |
367 | 367 | * @return mixed |
368 | 368 | */ |
369 | - public function getType():? string |
|
369 | + public function getType(): ? string |
|
370 | 370 | { |
371 | 371 | return $this->type; |
372 | 372 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @throws BadResponseException |
31 | 31 | * @throws ConnectException |
32 | 32 | */ |
33 | - public function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
33 | + public function create(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface |
|
34 | 34 | { |
35 | - return $this->request('post', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
35 | + return $this->request('post', $checkout, $accessToken, self::getScopes()) ? $checkout : null; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * @throws BadResponseException |
41 | 41 | * @throws ConnectException |
42 | 42 | */ |
43 | - public function get(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
43 | + public function get(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface |
|
44 | 44 | { |
45 | - return $this->request('get', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
45 | + return $this->request('get', $checkout, $accessToken, self::getScopes()) ? $checkout : null; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | * @throws BadResponseException |
52 | 52 | * @throws ConnectException |
53 | 53 | */ |
54 | - public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
|
54 | + public function complete(CheckoutInterface $checkout, AccessToken $accessToken = null): ? CheckoutInterface |
|
55 | 55 | { |
56 | - return $this->request('put', $checkout, $accessToken, self::getScopes())? $checkout: null; |
|
56 | + return $this->request('put', $checkout, $accessToken, self::getScopes()) ? $checkout : null; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @throws BadResponseException |
66 | 66 | * @throws ConnectException |
67 | 67 | */ |
68 | - protected function request(string $action, CheckoutInterface $checkout, AccessToken $accessToken, array $scopes):? bool |
|
68 | + protected function request(string $action, CheckoutInterface $checkout, AccessToken $accessToken, array $scopes): ? bool |
|
69 | 69 | { |
70 | 70 | $accessToken = AuthenticationHelper::getValidToken($this->context, $accessToken, $scopes??self::getScopes()); |
71 | 71 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | $options['form_params'] = self::getCheckoutBody($checkout); |
75 | 75 | |
76 | 76 | $uri = self::ENDPOINT . '/' . $checkout->getId(); |
77 | - if($action=='post'){ |
|
77 | + if ($action == 'post') { |
|
78 | 78 | $uri = self::ENDPOINT; |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** @var Response $response */ |
82 | 82 | $response = $client->{$action}($uri, $options); |
83 | 83 | $this->lastResponse = $response; |
84 | - if($response->getStatusCode() < 300 && $response->getStatusCode() >= 200){ |
|
84 | + if ($response->getStatusCode() < 300 && $response->getStatusCode() >= 200) { |
|
85 | 85 | $hydrator = SumUp::getHydrator(); |
86 | 86 | $data = \GuzzleHttp\json_decode($response->getBody(), true); |
87 | 87 | $hydrator->hydrate($data, $checkout); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @return float |
44 | 44 | */ |
45 | - function getAmount():? float; |
|
45 | + function getAmount(): ? float; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @return float|null |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | /** |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - function getValidUntil():? string; |
|
149 | + function getValidUntil(): ? string; |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * @param string $timestamp |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | /** |
213 | 213 | * @return null|string |
214 | 214 | */ |
215 | - function getType():? string; |
|
215 | + function getType(): ? string; |
|
216 | 216 | |
217 | - function setInstallments(?string $installments):? self; |
|
218 | - function getInstallments():? string; |
|
217 | + function setInstallments(?string $installments): ? self; |
|
218 | + function getInstallments(): ? string; |
|
219 | 219 | |
220 | 220 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class InvalidCheckoutException extends \RuntimeException |
8 | 8 | { |
9 | - public function __construct($message = "",CheckoutInterface $checkout, $code = 0, Throwable $previous = null) |
|
9 | + public function __construct($message = "", CheckoutInterface $checkout, $code = 0, Throwable $previous = null) |
|
10 | 10 | { |
11 | 11 | $message = sprintf(<<<MSG |
12 | 12 | %s |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | public function __construct($object, $property, Throwable $previous = null) |
17 | 17 | { |
18 | - $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
18 | + $message = sprintf('Not allowed property %s into %s class!', $property, get_class($object)); |
|
19 | 19 | parent::__construct($message, 100, $previous); |
20 | 20 | } |
21 | 21 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'headers' => $headers |
72 | 72 | ], $body); |
73 | 73 | $successul = $response->getStatusCode() === 201; |
74 | - } catch(\GuzzleHttp\Exception\RequestException $e){ |
|
74 | + } catch (\GuzzleHttp\Exception\RequestException $e) { |
|
75 | 75 | throw new BadRequestException( |
76 | 76 | $e->getMessage(), |
77 | 77 | $e->getRequest(), |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | return null; |
89 | 89 | } |
90 | 90 | |
91 | - private function request(string $action, CustomerInterface $customer, AccessToken $accessToken, array $scopes):? CustomerInterface |
|
91 | + private function request(string $action, CustomerInterface $customer, AccessToken $accessToken, array $scopes): ? CustomerInterface |
|
92 | 92 | { |
93 | 93 | $accessToken = AuthenticationHelper::getValidToken( |
94 | 94 | $this->context, |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | $options = AuthenticationHelper::getOAuthHeader($accessToken); |
101 | 101 | $options['form_params'] = self::getCustomerBody($customer); |
102 | 102 | |
103 | - $successCode=200; |
|
103 | + $successCode = 200; |
|
104 | 104 | $uri = self::ENDPOINT . '/' . $customer->getCustomerId(); |
105 | - switch (true){ |
|
106 | - case $action==='create': { |
|
107 | - $action='post'; |
|
108 | - $successCode=201; |
|
105 | + switch (true) { |
|
106 | + case $action === 'create': { |
|
107 | + $action = 'post'; |
|
108 | + $successCode = 201; |
|
109 | 109 | $uri = self::ENDPOINT; |
110 | 110 | break; |
111 | 111 | } |
112 | - case $action==='complete': { |
|
113 | - $action='put'; |
|
112 | + case $action === 'complete': { |
|
113 | + $action = 'put'; |
|
114 | 114 | break; |
115 | 115 | } |
116 | 116 | default:{ |
117 | - $action='get'; |
|
117 | + $action = 'get'; |
|
118 | 118 | break; |
119 | 119 | } |
120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | /** @var ResponseInterface $response */ |
123 | 123 | $response = $client->{$action}($uri, $options); |
124 | 124 | $this->lastResponse = $response; |
125 | - if($successCode===$response->getStatusCode()){ |
|
125 | + if ($successCode === $response->getStatusCode()) { |
|
126 | 126 | $wrapper = new Hydrator($response); |
127 | 127 | return $wrapper->hydrate($customer); |
128 | 128 | } |