Completed
Push — master ( ddb885...bba056 )
by Fabian
02:59
created

OpenOrdersRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 61
ccs 0
cts 25
cp 0
rs 10
c 1
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseClassName() 0 3 1
A __construct() 0 4 1
A getVisibility() 0 3 1
A getMethod() 0 3 1
A getRequestData() 0 9 2
1
<?php
2
3
namespace HanischIt\KrakenApi\Model\OpenOrders;
4
5
use HanischIt\KrakenApi\Enum\VisibilityEnum;
6
use HanischIt\KrakenApi\Model\RequestInterface;
7
8
/**
9
 * Class OpenOrdersRequest
10
 *
11
 * @package HanischIt\KrakenApi\Model\OpenOrders
12
 */
13
class OpenOrdersRequest implements RequestInterface
14
{
15
    /**
16
     * @var bool
17
     */
18
    private $trades;
19
    /**
20
     * @var string|null
21
     */
22
    private $userref;
23
24
    /**
25
     * OrderBookRequest constructor.
26
     *
27
     * @param bool $trades
28
     * @param null $userref
29
     */
30
    public function __construct($trades = false, $userref = null)
31
    {
32
        $this->trades = $trades;
33
        $this->userref = $userref;
34
    }
35
36
    /**
37
     * Returns the api request name
38
     *
39
     * @return string
40
     */
41
    public function getMethod()
42
    {
43
        return 'OpenOrders';
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getVisibility()
50
    {
51
        return VisibilityEnum::VISIBILITY_PRIVATE;
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function getRequestData()
58
    {
59
        $arr = [];
60
        $arr["trades"] = $this->trades;
61
        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...
62
            $arr["userref"] = $this->userref;
63
        }
64
65
        return $arr;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getResponseClassName()
72
    {
73
        return OpenOrdersResponse::class;
74
    }
75
}
76