Completed
Push — master ( 326999...39a0bd )
by Fabian
02:17
created

OpenPositionsResponse::manualMapping()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 18
nc 2
nop 1
dl 0
loc 20
ccs 19
cts 19
cp 1
crap 2
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Model\OpenPositions;
4
5
use HanischIt\KrakenApi\Model\ResponseInterface;
6
7
/**
8
 * Class OpenPositionsResponse
9
 * @package HanischIt\KrakenApi\Model\OpenPositions
10
 */
11
class OpenPositionsResponse implements ResponseInterface
12
{
13
    /**
14
     * @var OpenPositionModel[]
15
     */
16
    private $positions = [];
17
18
    /**
19
     * @param array $result
20
     */
21 1
    public function manualMapping($result)
22
    {
23 1
        foreach ($result as $txId => $position) {
24 1
            $this->positions[] = new OpenPositionModel(
25 1
                $txId,
26 1
                $position["ordertxid"],
27 1
                $position["pair"],
28 1
                $position["time"],
29 1
                $position["type"],
30 1
                $position["ordertype"],
31 1
                $position["cost"],
32 1
                $position["fee"],
33 1
                $position["vol"],
34 1
                $position["vol_closed"],
35 1
                $position["margin"],
36 1
                $position["value"],
37 1
                $position["net"],
38 1
                $position["misc"],
39 1
                $position["oflags"],
40 1
                $position["viqc"]
41 1
            );
42 1
        }
43 1
    }
44
45
    /**
46
     * @return OpenPositionModel[]
47
     */
48 1
    public function getPositions()
49
    {
50 1
        return $this->positions;
51
    }
52
53
}
54