Passed
Push — master ( 80a2af...b754d5 )
by Fabian
51s
created

OHLCDataResponse::manualMapping()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 3
nop 1
dl 0
loc 12
ccs 8
cts 8
cp 1
crap 4
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\OHLCData;
4
5
use HanischIt\KrakenApi\Call\OHLCData\Model\OHLCDataModel;
6
use HanischIt\KrakenApi\Model\ResponseInterface;
7
8
/**
9
 * Class OHLCDataResponse
10
 * @package HanischIt\KrakenApi\Call\OHLCData
11
 */
12
class OHLCDataResponse implements ResponseInterface
13
{
14
15
    /**
16
     *
17
     * @var int
18
     */
19
    private $last;
20
21
    /**
22
     * @var OHLCDataModel[]
23
     */
24
    private $ohlcDataModels;
25
26
    /**
27
     * @param array $data
28
     */
29 1
    public function manualMapping($data)
30
    {
31 1
        $this->last = $data["last"];
32
33 1
        foreach ($data as $assetPair => $assetDataArr) {
34 1
            if ($assetPair == "last") {
35 1
                continue;
36
            }
37
38 1
            foreach ($assetDataArr as $assetData) {
39 1
                $this->ohlcDataModels[] = new OHLCDataModel($assetData[0], $assetData[1], $assetData[2], $assetData[3],
40 1
                    $assetData[4], $assetData[5], $assetData[6], $assetData[7]);
41 1
            }
42 1
        }
43 1
    }
44
45
    /**
46
     * @return int
47
     */
48 1
    public function getLast()
49
    {
50 1
        return $this->last;
51
    }
52
53
    /**
54
     * @return OHLCDataModel[]
55
     */
56 1
    public function getOhlcDataModels()
57
    {
58 1
        return $this->ohlcDataModels;
59
    }
60
}
61