Completed
Push — master ( 3ad417...37b5d9 )
by Fabian
02:10
created

OrdersInfoAbstractRequest::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Model\OrdersInfo;
4
5
use HanischIt\KrakenApi\Enum\VisibilityEnum;
6
use HanischIt\KrakenApi\Model\AbstractRequest;
7
8
/**
9
 * Class OrdersInfoAbstractRequest
10
 * @package HanischIt\KrakenApi\Model\OrdersInfo
11
 */
12
class OrdersInfoAbstractRequest extends AbstractRequest
13
{
14
    /**
15
     * @var bool
16
     */
17
    private $trades;
18
    /**
19
     * @var string|null
20
     */
21
    private $userref;
22
    /**
23
     * @var string
24
     */
25
    private $txids;
26
27
    /**
28
     * OrdersInfoAbstractRequest constructor.
29
     * @param bool $trades
30
     * @param null|string $userref
31
     * @param null|string[] $txids
32
     */
33 2
    public function __construct(array $txids, $trades = false, $userref = null)
34
    {
35 2
        $this->trades = $trades;
36 2
        if (null !== $userref) {
37 1
            $this->userref = $userref;
38 1
        }
39
40 2
        $this->txids = implode(",", $txids);
41 2
    }
42
43
44
    /**
45
     * Returns the api request name
46
     *
47
     * @return string
48
     */
49 1
    public function getMethod()
50
    {
51 1
        return 'QueryOrders';
52
    }
53
54
    /**
55
     * @return string
56
     */
57 1
    public function getVisibility()
58
    {
59 1
        return VisibilityEnum::VISIBILITY_PRIVATE;
60
    }
61
62
    /**
63
     * @return array
64
     */
65 1
    public function getRequestData()
66
    {
67 1
        $ret = [];
68 1
        $ret["trades"] = $this->trades;
69 1
        if (null !== $this->userref) {
70 1
            $ret["userref"] = $this->userref;
71 1
        }
72 1
        if (null !== $this->txids) {
73 1
            $ret["txid"] = $this->txids;
74 1
        }
75 1
        return $ret;
76
    }
77
78
    /**
79
     * @return string
80
     */
81 1
    public function getResponseClassName()
82
    {
83 1
        return OrdersInfoResponse::class;
84
    }
85
}
86