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

OpenPositionsResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 40
ccs 24
cts 24
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPositions() 0 3 1
A manualMapping() 0 20 2
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