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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 76
ccs 20
cts 20
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 15 2
A __construct() 0 19 1
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