Passed
Pull Request — master (#23)
by Volodymyr
05:28
created

AbstractAuthorizationContainer::setCurrency()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization;
9
10
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer;
11
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PaymentMethod\AbstractPaymentMethodContainer;
12
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainerInterface;
13
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\TransactionContainer;
14
15
abstract class AbstractAuthorizationContainer extends AbstractRequestContainer implements AuthorizationContainerInterface
16
{
17
    /**
18
     * Sub account ID
19
     *
20
     * @var int
21
     */
22
    protected $aid;
23
24
    /**
25
     * @var string
26
     */
27
    protected $clearingtype;
28
29
    /**
30
     * @var string
31
     */
32
    protected $clearingsubtype;
33
34
    /**
35
     * Merchant reference number for the payment process. (Permitted symbols: 0-9, a-z, A-Z, .,-,_,/)
36
     *
37
     * @var string
38
     */
39
    protected $reference;
40
41
    /**
42
     * Total amount (in smallest currency unit! e.g. cent)
43
     *
44
     * @var int
45
     */
46
    protected $amount;
47
48
    /**
49
     * Currency (ISO-4217)
50
     *
51
     * @var string
52
     */
53
    protected $currency;
54
55
    /**
56
     * Individual parameter
57
     *
58
     * @var string
59
     */
60
    protected $param;
61
62
    /**
63
     * dynamic text for debit and creditcard payments
64
     *
65
     * @var string
66
     */
67
    protected $narrative_text;
68
69
    /**
70
     * @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PersonalContainer
71
     */
72
    protected $personalData;
73
74
    /**
75
     * @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\ShippingContainer
76
     */
77
    protected $shippingData;
78
79
    /**
80
     * @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PaymentMethod\AbstractPaymentMethodContainer
81
     */
82
    protected $paymentMethod;
83
84
    /**
85
     * @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\ThreeDSecureContainer
86
     */
87
    protected $_3dsecure;
88
89
    /**
90
     * @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\TransactionContainer
91
     */
92
    protected $invoicing;
93
94
    /**
95
     * @var string
96
     */
97
    protected $onlinebanktransfertype;
98
99
    /**
100
     * @var string
101
     */
102
    protected $bankcountry;
103
104
    /**
105
     * @var string
106
     */
107
    protected $businessrelation;
108
109
    /**
110
     * @return string|null
111
     */
112
    public function getBusinessrelation(): ?string
113
    {
114
        return $this->businessrelation;
115
    }
116
117
    /**
118
     * @param string $businessrelation
119
     */
120
    public function setBusinessrelation(string $businessrelation): void
121
    {
122
        $this->businessrelation = $businessrelation;
123
    }
124
125
    /**
126
     * @var array
127
     */
128
    protected $it;
129
130
    /**
131
     * @var array
132
     */
133
    protected $id;
134
135
    /**
136
     * @var array
137
     */
138
    protected $pr;
139
140
    /**
141
     * @var array
142
     */
143
    protected $no;
144
145
    /**
146
     * @var array
147
     */
148
    protected $de;
149
150
    /**
151
     * @var array
152
     */
153
    protected $va;
154
155
    /**
156
     * @var string
157
     */
158
    protected $email;
159
160
    /**
161
     * @param int $aid
162
     *
163
     * @return void
164
     */
165
    public function setAid($aid)
166
    {
167
        $this->aid = $aid;
168
    }
169
170
    /**
171
     * @return int
172
     */
173
    public function getAid()
174
    {
175
        return $this->aid;
176
    }
177
178
    /**
179
     * @param int $amount
180
     *
181
     * @return void
182
     */
183
    public function setAmount($amount)
184
    {
185
        $this->amount = $amount;
186
    }
187
188
    /**
189
     * @return int
190
     */
191
    public function getAmount()
192
    {
193
        return $this->amount;
194
    }
195
196
    /**
197
     * @param string $clearingType
198
     *
199
     * @return void
200
     */
201
    public function setClearingType($clearingType)
202
    {
203
        $this->clearingtype = $clearingType;
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    public function getClearingType()
210
    {
211
        return $this->clearingtype;
212
    }
213
214
    /**
215
     * @param string $currency
216
     *
217
     * @return void
218
     */
219
    public function setCurrency($currency)
220
    {
221
        $this->currency = $currency;
222
    }
223
224
    /**
225
     * @return string
226
     */
227
    public function getCurrency()
228
    {
229
        return $this->currency;
230
    }
231
232
    /**
233
     * @param string $narrative_text
234
     *
235
     * @return void
236
     */
237
    public function setNarrativeText($narrative_text)
238
    {
239
        $this->narrative_text = $narrative_text;
240
    }
241
242
    /**
243
     * @return string
244
     */
245
    public function getNarrativeText()
246
    {
247
        return $this->narrative_text;
248
    }
249
250
    /**
251
     * @param string $param
252
     *
253
     * @return void
254
     */
255
    public function setParam($param)
256
    {
257
        $this->param = $param;
258
    }
259
260
    /**
261
     * @return string
262
     */
263
    public function getParam()
264
    {
265
        return $this->param;
266
    }
267
268
    /**
269
     * @param string $reference
270
     *
271
     * @return void
272
     */
273
    public function setReference($reference)
274
    {
275
        $this->reference = $reference;
276
    }
277
278
    /**
279
     * @return string
280
     */
281
    public function getReference()
282
    {
283
        return $this->reference;
284
    }
285
286
    /**
287
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PersonalContainer $personalData
288
     *
289
     * @return void
290
     */
291
    public function setPersonalData(PersonalContainer $personalData)
292
    {
293
        $this->personalData = $personalData;
294
    }
295
296
    /**
297
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PersonalContainer
298
     */
299
    public function getPersonalData()
300
    {
301
        return $this->personalData;
302
    }
303
304
    /**
305
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\ShippingContainer $delivery
306
     *
307
     * @return void
308
     */
309
    public function setShippingData(ShippingContainer $delivery)
310
    {
311
        $this->shippingData = $delivery;
312
    }
313
314
    /**
315
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\ShippingContainer
316
     */
317
    public function getShippingData()
318
    {
319
        return $this->shippingData;
320
    }
321
322
    /**
323
     * @param PaymentMethod\AbstractPaymentMethodContainer $paymentMethod
324
     *
325
     * @return void
326
     */
327
    public function setPaymentMethod(AbstractPaymentMethodContainer $paymentMethod)
328
    {
329
        $this->paymentMethod = $paymentMethod;
330
    }
331
332
    /**
333
     * @return PaymentMethod\AbstractPaymentMethodContainer
334
     */
335
    public function getPaymentMethod()
336
    {
337
        return $this->paymentMethod;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->paymentMethod; (SprykerEco\Zed\Payone\Bu...tPaymentMethodContainer) is incompatible with the return type declared by the interface SprykerEco\Zed\Payone\Bu...rface::getPaymentMethod of type SprykerEco\Zed\Payone\Bu...tPaymentMethodContainer.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
338
    }
339
340
    /**
341
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\ThreeDSecureContainer $secure
342
     *
343
     * @return void
344
     */
345
    public function set3dsecure(ThreeDSecureContainer $secure)
346
    {
347
        $this->_3dsecure = $secure;
348
    }
349
350
    /**
351
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\ThreeDSecureContainer
352
     */
353
    public function get3dsecure()
354
    {
355
        return $this->_3dsecure;
356
    }
357
358
    /**
359
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\TransactionContainer $invoicing
360
     *
361
     * @return void
362
     */
363
    public function setInvoicing(TransactionContainer $invoicing)
364
    {
365
        $this->invoicing = $invoicing;
366
    }
367
368
    /**
369
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\TransactionContainer
370
     */
371
    public function getInvoicing()
372
    {
373
        return $this->invoicing;
374
    }
375
376
    /**
377
     * @return string
378
     */
379
    public function getOnlinebanktransfertype()
380
    {
381
        return $this->onlinebanktransfertype;
382
    }
383
384
    /**
385
     * @param string $onlinebanktransfertype
386
     *
387
     * @return void
388
     */
389
    public function setOnlinebanktransfertype($onlinebanktransfertype)
390
    {
391
        $this->onlinebanktransfertype = $onlinebanktransfertype;
392
    }
393
394
    /**
395
     * @return string
396
     */
397
    public function getClearingsubtype(): string
398
    {
399
        return $this->clearingsubtype;
400
    }
401
402
    /**
403
     * @param string $clearingsubtype
404
     *
405
     * @return void
406
     */
407
    public function setClearingsubtype(string $clearingsubtype): void
408
    {
409
        $this->clearingsubtype = $clearingsubtype;
410
    }
411
412
    /**
413
     * @return array
414
     */
415
    public function getIt(): array
416
    {
417
        return $this->it;
418
    }
419
420
    /**
421
     * @param array $it
422
     */
423
    public function setIt(array $it): void
424
    {
425
        $this->it = $it;
426
    }
427
428
    /**
429
     * @return array
430
     */
431
    public function getId(): array
432
    {
433
        return $this->id;
434
    }
435
436
    /**
437
     * @param array $id
438
     */
439
    public function setId(array $id): void
440
    {
441
        $this->id = $id;
442
    }
443
444
    /**
445
     * @return array
446
     */
447
    public function getPr(): array
448
    {
449
        return $this->pr;
450
    }
451
452
    /**
453
     * @param array $pr
454
     */
455
    public function setPr(array $pr): void
456
    {
457
        $this->pr = $pr;
458
    }
459
460
    /**
461
     * @return array
462
     */
463
    public function getNo(): array
464
    {
465
        return $this->no;
466
    }
467
468
    /**
469
     * @param array $no
470
     */
471
    public function setNo(array $no): void
472
    {
473
        $this->no = $no;
474
    }
475
476
    /**
477
     * @return array
478
     */
479
    public function getDe(): array
480
    {
481
        return $this->de;
482
    }
483
484
    /**
485
     * @param array $de
486
     */
487
    public function setDe(array $de): void
488
    {
489
        $this->de = $de;
490
    }
491
492
    /**
493
     * @return array
494
     */
495
    public function getVa(): array
496
    {
497
        return $this->va;
498
    }
499
500
    /**
501
     * @param array $va
502
     */
503
    public function setVa(array $va): void
504
    {
505
        $this->va = $va;
506
    }
507
508
    /**
509
     * @return string
510
     */
511
    public function getEmail(): string
512
    {
513
        return $this->email;
514
    }
515
516
    /**
517
     * @param string $email
518
     */
519
    public function setEmail(string $email): void
520
    {
521
        $this->email = $email;
522
    }
523
}
524