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

RecentTradesResponse::getTradeModel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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