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

TradesHistoryResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 19.05 %

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
dl 8
loc 42
ccs 13
cts 15
cp 0.8667
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

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