Event   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 19
dl 0
loc 92
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getNewDueDate() 0 3 1
A getStatus() 0 3 1
A getReason() 0 3 1
A getReasonCode() 0 3 1
A __construct() 0 14 1
A getAttempt() 0 3 1
A getRecordedOn() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\eCurring\Resource\Transaction;
6
7
use DateTimeImmutable;
8
use LauLamanApps\eCurring\Resource\Transaction\Event\ReasonCode;
9
10
final class Event
11
{
12
    /**
13
     * @var int
14
     *
15
     * The current collection attempt.
16
     * Starts at 1 and will be increased after every re-schedule.
17
     */
18
    private $attempt;
19
    /**
20
     * @var DateTimeImmutable
21
     *
22
     * The date and time on which this event was record.
23
     */
24
    private $recordedOn;
25
26
    /**
27
     * @var Status
28
     *
29
     * The status of the transaction at this point in time.
30
     */
31
    private $status;
32
33
    /**
34
     * @var DateTimeImmutable|null
35
     *
36
     * This contains the new due date in this point in time when a transaction is rescheduled.
37
     * Only available when $status is 'rescheduled'
38
     */
39
    private $newDueDate;
40
41
42
    /**
43
     * @var string|null
44
     *
45
     * The charge back or failure reason.
46
     * Only provided when the status is 'charged_back' or 'failed'
47
     */
48
    private $reason;
49
50
    /**
51
     * @var ReasonCode|null
52
     *
53
     * The SEPA charge back or failure reason code.
54
     * Only provided when the status is 'charged_back' or 'failed'
55
     */
56
    private $reasonCode;
57
58
    public function __construct(
59
        int $attempt,
60
        DateTimeImmutable $recordedOn,
61
        Status $status,
62
        ?DateTimeImmutable $newDueDate,
63
        ?string $reason,
64
        ?ReasonCode $reasonCode
65
    ) {
66
        $this->attempt = $attempt;
67
        $this->reason = $reason;
68
        $this->status = $status;
69
        $this->newDueDate = $newDueDate;
70
        $this->reasonCode = $reasonCode;
71
        $this->recordedOn = $recordedOn;
72
    }
73
74
    public function getAttempt(): int
75
    {
76
        return $this->attempt;
77
    }
78
79
    public function getRecordedOn(): DateTimeImmutable
80
    {
81
        return $this->recordedOn;
82
    }
83
84
    public function getStatus(): Status
85
    {
86
        return $this->status;
87
    }
88
89
    public function getNewDueDate(): ?DateTimeImmutable
90
    {
91
        return $this->newDueDate;
92
    }
93
94
    public function getReason(): ?string
95
    {
96
        return $this->reason;
97
    }
98
99
    public function getReasonCode(): ?ReasonCode
100
    {
101
        return $this->reasonCode;
102
    }
103
}
104