Passed
Push — master ( bba056...1b0f90 )
by Fabian
02:22
created

ClosedOrdersRequest::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace HanischIt\KrakenApi\Model\ClosedOrders;
4
5
use HanischIt\KrakenApi\Enum\VisibilityEnum;
6
use HanischIt\KrakenApi\Model\RequestInterface;
7
8
/**
9
 * Class ClosedOrdersRequest
10
 *
11
 * @package HanischIt\KrakenApi\Model\ClosedOrders
12
 */
13
class ClosedOrdersRequest implements RequestInterface
14
{
15
    /**
16
     * @var bool
17
     */
18
    private $trades;
19
    /**
20
     * @var string|null
21
     */
22
    private $userref;
23
    /**
24
     * @var null|string
25
     */
26
    private $start;
27
    /**
28
     * @var null|string
29
     */
30
    private $end;
31
    /**
32
     * @var int|null
33
     */
34
    private $ofs;
35
    /**
36
     * @var null|string
37
     */
38
    private $closetime;
39
40
    /**
41
     * OrderBookRequest constructor.
42
     *
43
     * @param bool        $trades
44
     * @param null|string $userref
45
     * @param null|string $start
46
     * @param null|string $end
47
     * @param null|int    $ofs
48
     * @param null|string $closetime
49
     */
50
    public function __construct($trades = false, $userref = null, $start = null, $end = null, $ofs = null, $closetime = null)
51
    {
52
        $this->trades = $trades;
53
        $this->userref = $userref;
54
        $this->start = $start;
55
        $this->end = $end;
56
        $this->ofs = $ofs;
57
        $this->closetime = $closetime;
58
    }
59
60
    /**
61
     * Returns the api request name
62
     *
63
     * @return string
64
     */
65
    public function getMethod()
66
    {
67
        return 'ClosedOrders';
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getVisibility()
74
    {
75
        return VisibilityEnum::VISIBILITY_PRIVATE;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public function getRequestData()
82
    {
83
        $arr = [];
84
        $arr["trades"] = $this->trades;
85
        if ($this->userref) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->userref of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
86
            $arr["userref"] = $this->userref;
87
        }
88
        if ($this->start) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->start of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
89
            $arr["start"] = $this->start;
90
        }
91
        if ($this->end) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->end of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
92
            $arr["end"] = $this->end;
93
        }
94
        if ($this->ofs) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->ofs of type null|integer is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
95
            $arr["ofs"] = $this->ofs;
96
        }
97
        if ($this->closetime) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->closetime of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
98
            $arr["closetime"] = $this->closetime;
99
        }
100
101
        return $arr;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getResponseClassName()
108
    {
109
        return ClosedOrdersResponse::class;
110
    }
111
}
112