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

TradesHistoryResponse::manualMapping()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 7
Ratio 70 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 7
loc 10
ccs 7
cts 9
cp 0.7778
crap 3.0987
rs 9.4285
c 0
b 0
f 0
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