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

OpenOrdersResponse::manualMapping()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 29
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 26
nc 2
nop 1
dl 0
loc 29
ccs 28
cts 28
cp 1
crap 2
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\OpenOrders;
4
5
use HanischIt\KrakenApi\Call\Shared\Model\OrderModel;
6
use HanischIt\KrakenApi\Call\Shared\Model\OrderTypeModel;
7
use HanischIt\KrakenApi\Model\ResponseInterface;
8
9
10
/**
11
 * Class OpenOrdersResponse
12
 * @package HanischIt\KrakenApi\Call\OpenOrders
13
 */
14
class OpenOrdersResponse implements ResponseInterface
15
{
16
    /**
17
     * @var \HanischIt\KrakenApi\Call\Shared\Model\OrderModel[]
18
     */
19
    private $orders;
20
21
    /**
22
     * @param array $result
23
     */
24 1
    public function manualMapping($result)
25
    {
26 1
        foreach ($result["open"] as $txid => $orderData) {
27 1
            $this->orders[] = new OrderModel(
28 1
                $txid,
29 1
                null,
30 1
                $orderData["cost"],
31 1
                new OrderTypeModel(
32 1
                    $orderData["descr"]["leverage"],
33 1
                    $orderData["descr"]["order"],
34 1
                    $orderData["descr"]["ordertype"],
35 1
                    $orderData["descr"]["pair"],
36 1
                    $orderData["descr"]["price"],
37 1
                    $orderData["descr"]["price2"],
38 1
                    $orderData["descr"]["type"]
39 1
                ),
40 1
                $orderData["expiretm"],
41 1
                $orderData["fee"],
42 1
                $orderData["misc"],
43 1
                $orderData["oflags"],
44 1
                $orderData["opentm"],
45 1
                $orderData["price"],
46 1
                null,
47 1
                $orderData["refid"],
48 1
                $orderData["starttm"],
49 1
                $orderData["status"],
50 1
                $orderData["userref"],
51 1
                $orderData["vol"],
52 1
                $orderData["vol_exec"]
53 1
            );
54 1
        }
55 1
    }
56
57
    /**
58
     * @return \HanischIt\KrakenApi\Call\Shared\Model\OrderModel[]
59
     */
60 1
    public function getOrders()
61
    {
62 1
        return $this->orders;
63
    }
64
}
65