Passed
Push — master ( 80a2af...b754d5 )
by Fabian
51s
created

AddOrderRequest::getVisibility()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author  Fabian Hanisch
4
 * @since   16.07.2017 18:24
5
 * @version 1.0
6
 */
7
8
namespace HanischIt\KrakenApi\Call\AddOrder;
9
10
use HanischIt\KrakenApi\Enum\VisibilityEnum;
11
use HanischIt\KrakenApi\Model\RequestInterface;
12
13
/**
14
 * Class AddOrderRequest
15
 * @package HanischIt\KrakenApi\Call\AddOrder
16
 */
17
class AddOrderRequest implements RequestInterface
18
{
19
    /**
20
     * @var string
21
     */
22
    private $pair;
23
    /**
24
     * @var string
25
     */
26
    private $type;
27
    /**
28
     * @var string
29
     */
30
    private $orderType;
31
    /**
32
     * @var float
33
     */
34
    private $price;
35
    /**
36
     * @var float
37
     */
38
    private $volume;
39
    /**
40
     * @var bool
41
     */
42
    private $validateOnly;
43
44
    /**
45
     * AddOrderRequest constructor.
46
     *
47
     * @param string $pair
48
     * @param string $type
49
     * @param string $orderType
50
     * @param float $price
51
     * @param float $volume
52
     * @param bool $validateOnly
53
     */
54 3
    public function __construct($pair, $type, $orderType, $price, $volume, $validateOnly = false)
55
    {
56 3
        $this->pair = $pair;
57 3
        $this->type = $type;
58 3
        $this->orderType = $orderType;
59 3
        $this->price = $price;
60 3
        $this->volume = $volume;
61 3
        $this->validateOnly = $validateOnly;
62 3
    }
63
64
65
    /**
66
     * Returns the api request name
67
     *
68
     * @return string
69
     */
70 2
    public function getMethod()
71
    {
72 2
        return 'AddOrder';
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
        $ret = [];
89 2
        $ret["pair"] = $this->pair;
90 2
        $ret["type"] = $this->type;
91 2
        $ret["ordertype"] = $this->orderType;
92 2
        if ($this->price) {
93 1
            $ret["price"] = $this->price;
94 1
        }
95 2
        if ($this->volume) {
96 1
            $ret["volume"] = $this->volume;
97 1
        }
98 2
        if (false !== $this->validateOnly) {
99 1
            $ret["validate"] = $this->validateOnly;
100 1
        }
101
102 2
        return $ret;
103
    }
104
105
    /**
106
     * @return string
107
     */
108 2
    public function getResponseClassName()
109
    {
110 2
        return AddOrderResponse::class;
111
    }
112
}
113