Transaction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 39
c 2
b 0
f 0
dl 0
loc 113
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
A typeDescription() 0 4 2
1
<?php
2
3
namespace Endeken\OFX;
4
5
use DateTime;
6
7
class Transaction
8
{
9
    private static array $types = [
10
        'CREDIT' => 'Generic credit',
11
        'DEBIT' => 'Generic debit',
12
        'INT' => 'Interest earned or paid',
13
        'DIV' => 'Dividend',
14
        'FEE' => 'FI fee',
15
        'SRVCHG' => 'Service charge',
16
        'DEP' => 'Deposit',
17
        'ATM' => 'ATM debit or credit',
18
        'POS' => 'Point of sale debit or credit',
19
        'XFER' => 'Transfer',
20
        'CHECK' => 'Cheque',
21
        'PAYMENT' => 'Electronic payment',
22
        'CASH' => 'Cash withdrawal',
23
        'DIRECTDEP' => 'Direct deposit',
24
        'DIRECTDEBIT' => 'Merchant initiated debit',
25
        'REPEATPMT' => 'Repeating payment/standing order',
26
        'OTHER' => 'Other',
27
    ];
28
29
    /**
30
     * @var string
31
     */
32
    public string $type;
33
34
    /**
35
     * @var DateTime
36
     */
37
    public DateTime $date;
38
39
    /**
40
     * Date the user initiated the transaction, if known
41
     * @var ?DateTime
42
     */
43
    public ?DateTime $userInitiatedDate;
44
45
    /**
46
     * @var float
47
     */
48
    public float $amount;
49
50
    /**
51
     * @var string
52
     */
53
    public string $uniqueId;
54
55
    /**
56
     * @var string
57
     */
58
    public string $name;
59
60
    /**
61
     * @var string
62
     */
63
    public string $memo;
64
65
    /**
66
     * @var string
67
     */
68
    public string $sic;
69
70
    /**
71
     * @var string
72
     */
73
    public string $checkNumber;
74
75
    /**
76
     * Transaction constructor.
77
     *
78
     * @param string $type
79
     * @param float $amount
80
     * @param DateTime $date
81
     * @param ?DateTime $userInitiatedDate
82
     * @param string $uniqueId
83
     * @param string $name
84
     * @param string $memo
85
     * @param string $sic
86
     * @param string $checkNumber
87
     */
88
    public function __construct(
89
        string $type,
90
        float $amount,
91
        DateTime $date,
92
        ?DateTime $userInitiatedDate,
93
        string $uniqueId,
94
        string $name,
95
        string $memo,
96
        string $sic,
97
        string $checkNumber,
98
    )
99
    {
100
        $this->type = $type;
101
        $this->amount = $amount;
102
        $this->date = $date;
103
        $this->userInitiatedDate = $userInitiatedDate;
104
        $this->uniqueId = $uniqueId;
105
        $this->name = $name;
106
        $this->memo = $memo;
107
        $this->sic = $sic;
108
        $this->checkNumber = $checkNumber;
109
    }
110
111
    /**
112
     * Get the associated type description
113
     *
114
     * @return string
115
     */
116
    public function typeDescription(): string
117
    {
118
        $type = $this->type;
119
        return array_key_exists($type, self::$types) ? self::$types[$type] : '';
120
    }
121
}
122