Completed
Push — master ( a6a8a1...a2d76b )
by Fabian
06:14
created

TradesResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 31.03 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 9
loc 29
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTrades() 0 3 1
A manualMapping() 8 10 3

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\Trades;
4
5
use HanischIt\KrakenApi\Call\TradesHistory\Model\TradeModel;
6
use HanischIt\KrakenApi\Model\ResponseInterface;
7
8
/**
9
 * Class TradesResponse
10
 * @package HanischIt\KrakenApi\Call\Trades
11
 */
12
class TradesResponse implements ResponseInterface
13
{
14
    /**
15
     * @var \HanischIt\KrakenApi\Call\TradesHistory\Model\TradeModel[]
16
     */
17
    private $trades;
18
19
    /**
20
     * @param array $result
21
     */
22 1
    public function manualMapping($result)
23
    {
24 1 View Code Duplication
        foreach ($result as $txId => $trade) {
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...
25 1
            if (!isset($trade["closing"])) {
26
                $trade["closing"] = null;
27
            }
28
            
29 1
            $this->trades[] = new TradeModel($trade["ordertxid"], $trade["pair"], $trade["time"], $trade["type"],
30 1
                $trade["ordertype"], $trade["price"], $trade["cost"], $trade["fee"], $trade["vol"], $trade["margin"],
31 1
                $trade["misc"], $trade["closing"]);
32 1
        }
33 1
    }
34
35
    /**
36
     * @return TradeModel[]
37
     */
38 1
    public function getTrades()
39
    {
40 1
        return $this->trades;
41
    }
42
43
44
}
45