Passed
Push — master ( 9ff768...b736eb )
by Laurens
02:33
created

CardPayment::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 9.2
c 0
b 0
f 0
cc 1
eloc 20
nc 1
nop 10
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\API\Purchase\Payment;
6
7
use LauLamanApps\IzettleApi\API\Purchase\AbstractPayment;
8
use Money\Money;
9
use Ramsey\Uuid\UuidInterface;
10
11
final class CardPayment extends AbstractPayment
12
{
13
    private $referenceNumber;
14
    private $maskedPan;
15
    private $cardType;
16
    private $cardPaymentEntryMode;
17
    private $applicationName;
18
    private $applicationIdentifier;
19
    private $terminalVerificationResults;
20
    private $nrOfInstallments;
21
22 1
    public function __construct(
23
        UuidInterface $uuid,
24
        Money $amount,
25
        string $referenceNumber,
26
        string $maskedPan,
27
        string $cardType,
28
        string $cardPaymentEntryMode,
29
        ?string $applicationName = null,
30
        ?string $applicationIdentifier = null,
31
        ?string $terminalVerificationResults = null,
32
        ?int $nrOfInstallments = null
33
    ) {
34 1
        parent::__construct($uuid, $amount);
35 1
        $this->referenceNumber = $referenceNumber;
36 1
        $this->maskedPan = $maskedPan;
37 1
        $this->cardType = $cardType;
38 1
        $this->cardPaymentEntryMode = $cardPaymentEntryMode;
39 1
        $this->applicationName = $applicationName;
40 1
        $this->applicationIdentifier = $applicationIdentifier;
41 1
        $this->terminalVerificationResults = $terminalVerificationResults;
42 1
        $this->nrOfInstallments = $nrOfInstallments;
43 1
    }
44
45 1
    public function getReferenceNumber(): string
46
    {
47 1
        return $this->referenceNumber;
48
    }
49
50 1
    public function getMaskedPan(): string
51
    {
52 1
        return $this->maskedPan;
53
    }
54
55 1
    public function getCardType(): string
56
    {
57 1
        return $this->cardType;
58
    }
59
60 1
    public function getCardPaymentEntryMode(): string
61
    {
62 1
        return $this->cardPaymentEntryMode;
63
    }
64
65 1
    public function getApplicationName(): string
66
    {
67 1
        return $this->applicationName;
68
    }
69
70 1
    public function getApplicationIdentifier(): string
71
    {
72 1
        return $this->applicationIdentifier;
73
    }
74
75 1
    public function getTerminalVerificationResults(): string
76
    {
77 1
        return $this->terminalVerificationResults;
78
    }
79
80 1
    public function getNrOfInstallments(): int
81
    {
82 1
        return $this->nrOfInstallments;
83
    }
84
}
85