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

OrderBookResponse::manualMapping()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 14
Code Lines 7

Duplication

Lines 6
Ratio 42.86 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 5
nop 1
dl 6
loc 14
ccs 10
cts 10
cp 1
crap 4
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\OrderBook\Model;
4
5
use HanischIt\KrakenApi\Call\OrderBook\Model;
6
use HanischIt\KrakenApi\Model\ResponseInterface;
7
8
/**
9
 * Class OrderBookResponse
10
 * @package HanischIt\KrakenApi\Call\OrderBook
11
 */
12
class OrderBookResponse implements ResponseInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    private $assetPair;
18
    /**
19
     * @var OrderBookModel[]
20
     */
21
    private $asks = [];
22
    /**
23
     * @var OrderBookModel[]
24
     */
25
    private $bids = [];
26
27
    /**
28
     * @param array $result
29
     */
30 1
    public function manualMapping($result)
31
    {
32 1
        foreach ($result as $assetPair => $askBids) {
33 1
            $this->assetPair = $assetPair;
34
35 1 View Code Duplication
            foreach ($askBids["asks"] as $ask) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36 1
                $this->asks[] = new Model\OrderBookModel($ask[0], $ask[1], $ask[2]);
37 1
            }
38
39 1 View Code Duplication
            foreach ($askBids["bids"] as $bids) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40 1
                $this->bids[] = new Model\OrderBookModel($bids[0], $bids[1], $bids[2]);
41 1
            }
42
43 1
            break;
44 1
        }
45 1
    }
46
47
    /**
48
     * @return string
49
     */
50 1
    public function getAssetPair()
51
    {
52 1
        return $this->assetPair;
53
    }
54
55
    /**
56
     * @return \HanischIt\KrakenApi\Call\OrderBook\Model\OrderBookModel[]
57
     */
58 1
    public function getAsks()
59
    {
60 1
        return $this->asks;
61
    }
62
63
    /**
64
     * @return OrderBookModel[]
65
     */
66 1
    public function getBids()
67
    {
68 1
        return $this->bids;
69
    }
70
}
71