Pricing::loadPricing()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace OfxParser\Entities\Investment\Transaction\Traits;
4
5
use SimpleXMLElement;
6
7
/**
8
 * Combo for units, price, and total
9
 */
10
trait Pricing
11
{
12
    /**
13
     * @var float
14
     */
15
    public $units;
16
17
    /**
18
     * @var float
19
     */
20
    public $unitPrice;
21
22
    /**
23
     * @var float
24
     */
25
    public $total;
26
27
    /**
28
     * Where did the money for the transaction come from or go to?
29
     * CASH, MARGIN, SHORT, OTHER
30
     * @var string
31
     */
32
    public $subAccountFund;
33
34
    /**
35
     * Sub-account type for the security:
36
     * CASH, MARGIN, SHORT, OTHER
37
     * @var string
38
     */
39
    public $subAccountSec;
40
41
    /**
42
     * @param SimpleXMLElement $node
43
     * @return $this for chaining
44
     */
45
    protected function loadPricing(SimpleXMLElement $node)
46
    {
47
        $this->units = (string) $node->UNITS;
0 ignored issues
show
Documentation Bug introduced by
The property $units was declared of type double, but (string)$node->UNITS is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
48
        $this->unitPrice = (string) $node->UNITPRICE;
0 ignored issues
show
Documentation Bug introduced by
The property $unitPrice was declared of type double, but (string)$node->UNITPRICE is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
49
        $this->total = (string) $node->TOTAL;
0 ignored issues
show
Documentation Bug introduced by
The property $total was declared of type double, but (string)$node->TOTAL is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
50
        $this->subAccountFund = (string) $node->SUBACCTFUND;
51
        $this->subAccountSec = (string) $node->SUBACCTSEC;
52
53
        return $this;
54
    }
55
}
56