Completed
Push — master ( 39a0bd...0a53a0 )
by Fabian
02:26
created

OrderBookResponse   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 10.53 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 6
loc 57
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A manualMapping() 6 14 4
A getAssetPair() 0 3 1
A getBids() 0 3 1
A getAsks() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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