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

OrdersInfoResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 49
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
B manualMapping() 0 29 4
A getOrders() 0 3 1
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\OrdersInfo;
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
 * Class OrdersInfoResponse
11
 * @package HanischIt\KrakenApi\Call\OrdersInfo
12
 */
13
class OrdersInfoResponse implements ResponseInterface
14
{
15
    /**
16
     * @var OrderModel[]
17
     */
18
    private $orders;
19
20
    /**
21
     * @param array $result
22
     */
23 1
    public function manualMapping($result)
24
    {
25 1
        foreach ($result as $txid => $orderData) {
26 1
            $this->orders[] = new OrderModel(
27 1
                $txid,
28 1
                isset($orderData["closetm"]) ? $orderData["closetm"] : null,
29 1
                $orderData["cost"],
30 1
                new OrderTypeModel(
31 1
                    $orderData["descr"]["leverage"],
32 1
                    $orderData["descr"]["order"],
33 1
                    $orderData["descr"]["ordertype"],
34 1
                    $orderData["descr"]["pair"],
35 1
                    $orderData["descr"]["price"],
36 1
                    $orderData["descr"]["price2"],
37 1
                    $orderData["descr"]["type"]
38 1
                ),
39 1
                $orderData["expiretm"],
40 1
                $orderData["fee"],
41 1
                $orderData["misc"],
42 1
                $orderData["oflags"],
43 1
                $orderData["opentm"],
44 1
                $orderData["price"],
45 1
                isset($orderData["reason"]) ? $orderData["reason"] : null,
46 1
                $orderData["refid"],
47 1
                $orderData["starttm"],
48 1
                $orderData["status"],
49 1
                $orderData["userref"],
50 1
                $orderData["vol"],
51 1
                $orderData["vol_exec"]
52 1
            );
53 1
        }
54 1
    }
55
56
    /**
57
     * @return OrderModel[]
58
     */
59 1
    public function getOrders()
60
    {
61 1
        return $this->orders;
62
    }
63
}
64