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

ClosedOrdersRequest::getRequestData()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
eloc 13
nc 32
nop 0
dl 0
loc 21
ccs 19
cts 19
cp 1
crap 6
rs 8.7624
c 0
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Call\ClosedOrders;
4
5
use HanischIt\KrakenApi\Enum\VisibilityEnum;
6
use HanischIt\KrakenApi\Model\RequestInterface;
7
8
/**
9
 * Class ClosedOrdersRequest
10
 * @package HanischIt\KrakenApi\Call\ClosedOrders
11
 */
12
class ClosedOrdersRequest implements RequestInterface
13
{
14
    /**
15
     * @var bool
16
     */
17
    private $trades;
18
    /**
19
     * @var string|null
20
     */
21
    private $userref;
22
    /**
23
     * @var null|string
24
     */
25
    private $start;
26
    /**
27
     * @var null|string
28
     */
29
    private $end;
30
    /**
31
     * @var int|null
32
     */
33
    private $ofs;
34
    /**
35
     * @var null|string
36
     */
37
    private $closetime;
38
39
    /**
40
     * OrderBookRequest constructor.
41
     *
42
     * @param bool $trades
43
     * @param null|string $userref
44
     * @param null|string $start
45
     * @param null|string $end
46
     * @param null|int $ofs
47
     * @param null|string $closetime
48
     */
49 3
    public function __construct(
50
        $trades = false,
51
        $userref = null,
52
        $start = null,
53
        $end = null,
54
        $ofs = null,
55
        $closetime = null
56
    ) {
57 3
        $this->trades = $trades;
58 3
        $this->userref = $userref;
59 3
        $this->start = $start;
60 3
        $this->end = $end;
61 3
        $this->ofs = $ofs;
62 3
        $this->closetime = $closetime;
63 3
    }
64
65
    /**
66
     * Returns the api request name
67
     *
68
     * @return string
69
     */
70 2
    public function getMethod()
71
    {
72 2
        return 'ClosedOrders';
73
    }
74
75
    /**
76
     * @return string
77
     */
78 2
    public function getVisibility()
79
    {
80 2
        return VisibilityEnum::VISIBILITY_PRIVATE;
81
    }
82
83
    /**
84
     * @return array
85
     */
86 2
    public function getRequestData()
87
    {
88 2
        $arr = [];
89 2
        $arr["trades"] = $this->trades;
90 2
        if (null !== $this->userref) {
91 1
            $arr["userref"] = $this->userref;
92 1
        }
93 2
        if (null !== $this->start) {
94 1
            $arr["start"] = $this->start;
95 1
        }
96 2
        if (null !== $this->end) {
97 1
            $arr["end"] = $this->end;
98 1
        }
99 2
        if (null !== $this->ofs) {
100 1
            $arr["ofs"] = $this->ofs;
101 1
        }
102 2
        if (null !== $this->closetime) {
103 1
            $arr["closetime"] = $this->closetime;
104 1
        }
105
106 2
        return $arr;
107
    }
108
109
    /**
110
     * @return string
111
     */
112 2
    public function getResponseClassName()
113
    {
114 2
        return ClosedOrdersResponse::class;
115
    }
116
}
117