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

SpreadDataResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLast() 0 3 1
A manualMapping() 0 9 4
A getSpreads() 0 3 1
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\SpreadData;
4
5
use HanischIt\KrakenApi\Call\SpreadData\Model\SpreadDataModel;
6
use HanischIt\KrakenApi\Model\ResponseInterface;
7
8
/**
9
 * Class SpreadDataResponse
10
 * @package HanischIt\KrakenApi\Call\SpreadData
11
 */
12
class SpreadDataResponse implements ResponseInterface
13
{
14
    /**
15
     * @var int
16
     */
17
    private $last;
18
    /**
19
     * @var SpreadDataModel[]
20
     */
21
    private $spreads;
22
23
    /**
24
     * @param array $result
25
     */
26 3
    public function manualMapping($result)
27
    {
28 3
        $this->last = $result["last"];
29 3
        foreach ($result as $assetPair => $assetData) {
30 3
            if ($assetPair == "last") {
31 3
                continue;
32
            }
33 3
            foreach ($assetData as $data) {
34 3
                $this->spreads[] = new SpreadDataModel($data[0], $data[1], $data[2]);
35 3
            }
36 3
        }
37 3
    }
38
39
    /**
40
     * @return int
41
     */
42 1
    public function getLast()
43
    {
44 1
        return $this->last;
45
    }
46
47
    /**
48
     * @return SpreadDataModel[]
49
     */
50 1
    public function getSpreads()
51
    {
52 1
        return $this->spreads;
53
    }
54
}
55