GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DirectDebitPayment::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
crap 2
1
<?php
2
3
namespace CMPayments\PaymentSdk\Entities;
4
5
use Money\Money;
6
7
/**
8
 * Class DirectDebitPayment
9
 * @package CMPayments\PaymentSdk\Entities
10
 * @author Jory Geerts <[email protected]>
11
 */
12
class DirectDebitPayment extends Payment
13
{
14
    /**
15
     * @var string
16
     */
17
    private $description;
18
    /**
19
     * @var string
20
     */
21
    private $iban;
22
    /**
23
     * @var string
24
     */
25
    private $name;
26
    /**
27
     * @var string
28
     */
29
    private $mandateId;
30
    /**
31
     * @var \DateTime
32
     */
33
    private $mandateStartDate;
34
    /**
35
     * @var null|string
36
     */
37
    private $transactionDescription;
38
39
    /**
40
     * IdealPayment constructor.
41
     * @param Money $money
42
     * @param string $purchaseId
43
     * @param string $iban
44
     * @param string $name
45
     * @param string $mandateId
46
     * @param \DateTime $mandateStartDate
47
     * @param string $description
48
     * @param string $transactionDescription = null
49
     * @internal param string $bic
50
     */
51 1
    public function __construct(
52
        Money $money,
53
        $purchaseId,
54
        $iban,
55
        $name,
56
        $mandateId,
57
        \DateTime $mandateStartDate,
58
        $description,
59
        $transactionDescription = null
60
    ) {
61 1
        parent::__construct($money, 'DirectDebit', $purchaseId);
62
63 1
        $this->description = $description;
64 1
        $this->iban = $iban;
65 1
        $this->name = $name;
66 1
        $this->mandateId = $mandateId;
67 1
        $this->mandateStartDate = $mandateStartDate;
68 1
        $this->transactionDescription = $transactionDescription;
69 1
    }
70
71
    /** @inheritdoc */
72 1
    public function toArray()
73
    {
74 1
        $array = parent::toArray();
75 1
        $array['payment_details']['bank_account_number'] = $this->iban;
76 1
        $array['payment_details']['name'] = $this->name;
77 1
        $array['payment_details']['mandate_id'] = $this->mandateId;
78 1
        $array['payment_details']['mandate_start_date'] = $this->mandateStartDate->format('Y-m-d');
79 1
        $array['payment_details']['description'] = $this->description;
80
81 1
        if ($this->transactionDescription) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->transactionDescription of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
82 1
            $array['payment_details']['transaction_description'] = $this->transactionDescription;
83 1
        }
84
85 1
        return $array;
86
    }
87
}
88