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

InvTran   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 46
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadInvTran() 0 15 3
1
<?php
2
3
namespace OfxParser\Entities\Investment\Transaction\Traits;
4
5
use SimpleXMLElement;
6
use OfxParser\Utils;
7
8
/**
9
 * OFX 203 doc:
10
 * 13.9.2.4.1 General Transaction Aggregate <INVTRAN>
11
 *
12
 * Limited implementation
13
 */
14
trait InvTran
15
{
16
    /**
17
     * This is the unique identifier in the broker's system,
18
     * NOT to be confused with the UNIQUEID node for the security.
19
     * @var string
20
     */
21
    public $uniqueId;
22
23
    /**
24
     * Date the trade occurred
25
     * @var \DateTimeInterface
26
     */
27
    public $tradeDate;
28
29
    /**
30
     * Date the trade was settled
31
     * @var \DateTimeInterface
32
     */
33
    public $settlementDate;
34
35
    /**
36
     * Transaction memo, as provided from broker.
37
     * @var string
38
     */
39
    public $memo;
40
41
    /**
42
     * @param SimpleXMLElement $node
43
     * @return $this for chaining
44
     */
45
    protected function loadInvTran(SimpleXMLElement $node)
46
    {
47
        // <INVTRAN>
48
        //  - REQUIRED: <FITID>, <DTTRADE>
49
        //  - all others optional
50
        $this->uniqueId = (string) $node->FITID;
51
        $this->tradeDate = Utils::createDateTimeFromStr($node->DTTRADE);
52
        if (isset($node->DTSETTLE)) {
53
            $this->settlementDate = Utils::createDateTimeFromStr($node->DTSETTLE);
54
        }
55
        if (isset($node->MEMO)) {
56
            $this->memo = (string) $node->MEMO;
57
        }
58
59
        return $this;
60
    }
61
}
62