Passed
Branch master (e17e02)
by Jacques
02:12
created

Transaction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 30
c 2
b 0
f 0
dl 0
loc 79
ccs 0
cts 3
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A typeDesc() 0 5 2
1
<?php
2
3
namespace OfxParser\Entities;
4
5
class Transaction extends AbstractEntity
6
{
7
    private static $types = [
8
        'CREDIT' => 'Generic credit',
9
        'DEBIT' => 'Generic debit',
10
        'INT' => 'Interest earned or paid',
11
        'DIV' => 'Dividend',
12
        'FEE' => 'FI fee',
13
        'SRVCHG' => 'Service charge',
14
        'DEP' => 'Deposit',
15
        'ATM' => 'ATM debit or credit',
16
        'POS' => 'Point of sale debit or credit',
17
        'XFER' => 'Transfer',
18
        'CHECK' => 'Cheque',
19
        'PAYMENT' => 'Electronic payment',
20
        'CASH' => 'Cash withdrawal',
21
        'DIRECTDEP' => 'Direct deposit',
22
        'DIRECTDEBIT' => 'Merchant initiated debit',
23
        'REPEATPMT' => 'Repeating payment/standing order',
24
        'OTHER' => 'Other',
25
    ];
26
27
    /**
28
     * @var string
29
     */
30
    public $type;
31
32
    /**
33
     * Date the transaction was posted
34
     * @var \DateTimeInterface
35
     */
36
    public $date;
37
38
    /**
39
     * Date the user initiated the transaction, if known
40
     * @var \DateTimeInterface|null
41
     */
42
    public $userInitiatedDate;
43
44
    /**
45
     * @var float
46
     */
47
    public $amount;
48
49
    /**
50
     * @var string
51
     */
52
    public $uniqueId;
53
54
    /**
55
     * @var string
56
     */
57
    public $name;
58
59
    /**
60
     * @var string
61
     */
62
    public $memo;
63
64
    /**
65
     * @var string
66
     */
67
    public $sic;
68
69
    /**
70
     * @var string
71
     */
72
    public $checkNumber;
73
74
    /**
75
     * Get the associated type description
76
     *
77
     * @return string
78
     */
79
    public function typeDesc()
80
    {
81
        // Cast SimpleXMLObject to string
82
        $type = (string)$this->type;
83
        return array_key_exists($type, self::$types) ? self::$types[$type] : '';
84
    }
85
}
86