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

Banking   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 40
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadOfx() 0 12 1
A getProperties() 0 5 1
1
<?php
2
3
namespace OfxParser\Entities\Investment\Transaction;
4
5
use SimpleXMLElement;
6
use OfxParser\Utils;
7
use OfxParser\Entities\Inspectable;
8
use OfxParser\Entities\OfxLoadable;
9
use OfxParser\Entities\Transaction as BaseTransaction;
10
11
/**
12
 * Per OFX 203 doc, this is a wrapper for a <STMTTRN> node
13
 * (aka "Banking aggregate") with an additional <SUBACCTFUND> node.
14
 *
15
 * Requires Inspectable interface to match API of Invesetment entities
16
 * extending OfxParser\Entities\Investment.
17
 */
18
class Banking extends BaseTransaction implements OfxLoadable, Inspectable
19
{
20
    /**
21
     * @var string
22
     */
23
    public $nodeName = 'INVBANKTRAN';
24
25
    /**
26
     * @var string
27
     */
28
    public $subAccountFund;
29
30
    /**
31
     * Get a list of properties defined for this entity.
32
     * @return array array('prop_name' => 'prop_name', ...)
33
     */
34
    public function getProperties()
35
    {
36
        $props = array_keys(get_object_vars($this));
37
38
        return array_combine($props, $props);
39
    }
40
41
    /**
42
     * Imports the OFX data for this node.
43
     * @param SimpleXMLElement $node
44
     * @return $this
45
     */
46
    public function loadOfx(SimpleXMLElement $node)
47
    {
48
        // Duplication of code in Ofx::buildTransactions()
49
        $this->type = (string) $node->STMTTRN->TRNTYPE;
50
        $this->date = Utils::createDateTimeFromStr($node->STMTTRN->DTPOSTED);
51
        $this->amount = Utils::createAmountFromStr($node->STMTTRN->TRNAMT);
52
        $this->uniqueId = (string) $node->STMTTRN->FITID;
53
54
        // Could put this in another trait.
55
        $this->subAccountFund = (string) $node->SUBACCTFUND;
56
57
        return $this;
58
    }
59
}
60