Passed
Push — master ( a79025...0532d8 )
by Fabian
04:09
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 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
nc 5
nop 1
dl 6
loc 14
ccs 0
cts 11
cp 0
crap 20
rs 9.2
c 1
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Model\OrderBook;
4
5
use HanischIt\KrakenApi\Model\ResponseInterface;
6
7
/**
8
 * Class OrderBookResponse
9
 *
10
 * @package HanischIt\KrakenApi\Model\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
    public function manualMapping($result)
31
    {
32
        foreach ($result as $assetPair => $askBids) {
33
            $this->assetPair = $assetPair;
34
35 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
                $this->asks[] = new OrderBookModel($ask[0], $ask[1], $ask[2]);
37
            }
38
39 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
                $this->bids[] = new OrderBookModel($bids[0], $bids[1], $bids[2]);
41
            }
42
43
            break;
44
        }
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getAssetPair()
51
    {
52
        return $this->assetPair;
53
    }
54
55
    /**
56
     * @return OrderBookModel[]
57
     */
58
    public function getAsks()
59
    {
60
        return $this->asks;
61
    }
62
63
    /**
64
     * @return OrderBookModel[]
65
     */
66
    public function getBids()
67
    {
68
        return $this->bids;
69
    }
70
71
72
}
73