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

AddOrderAbstractRequest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 94
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getRequestData() 0 17 4
A getMethod() 0 3 1
A getVisibility() 0 3 1
A getResponseClassName() 0 3 1
1
<?php
2
/**
3
 * @author  Fabian Hanisch
4
 * @since   16.07.2017 18:24
5
 * @version 1.0
6
 */
7
8
namespace HanischIt\KrakenApi\Model\AddOrder;
9
10
use HanischIt\KrakenApi\Enum\VisibilityEnum;
11
use HanischIt\KrakenApi\Model\AbstractRequest;
12
13
/**
14
 * Class AddOrderAbstractRequest
15
 *
16
 * @package HanischIt\KrakenApi\Model\AddOrder
17
 */
18
class AddOrderAbstractRequest extends AbstractRequest
19
{
20
    /**
21
     * @var string
22
     */
23
    private $pair;
24
    /**
25
     * @var string
26
     */
27
    private $type;
28
    /**
29
     * @var string
30
     */
31
    private $orderType;
32
    /**
33
     * @var float
34
     */
35
    private $price;
36
    /**
37
     * @var float
38
     */
39
    private $volume;
40
    /**
41
     * @var bool
42
     */
43
    private $validateOnly;
44
45
    /**
46
     * AddOrderAbstractRequest constructor.
47
     *
48
     * @param string $pair
49
     * @param string $type
50
     * @param string $orderType
51
     * @param float  $price
52
     * @param float  $volume
53
     * @param bool   $validateOnly
54
     */
55 3
    public function __construct($pair, $type, $orderType, $price, $volume, $validateOnly = false)
56
    {
57 3
        $this->pair = $pair;
58 3
        $this->type = $type;
59 3
        $this->orderType = $orderType;
60 3
        $this->price = $price;
61 3
        $this->volume = $volume;
62 3
        $this->validateOnly = $validateOnly;
63 3
    }
64
65
66
    /**
67
     * Returns the api request name
68
     *
69
     * @return string
70
     */
71 2
    public function getMethod()
72
    {
73 2
        return 'AddOrder';
74
    }
75
76
    /**
77
     * @return string
78
     */
79 2
    public function getVisibility()
80
    {
81 2
        return VisibilityEnum::VISIBILITY_PRIVATE;
82
    }
83
84
    /**
85
     * @return array
86
     */
87 2
    public function getRequestData()
88
    {
89 2
        $ret = [];
90 2
        $ret["pair"] = $this->pair;
91 2
        $ret["type"] = $this->type;
92 2
        $ret["ordertype"] = $this->orderType;
93 2
        if ($this->price) {
94 1
            $ret["price"] = $this->price;
95 1
        }
96 2
        if ($this->volume) {
97 1
            $ret["volume"] = $this->volume;
98 1
        }
99 2
        if (false !== $this->validateOnly) {
100 1
            $ret["validate"] = $this->validateOnly;
101 1
        }
102
103 2
        return $ret;
104
    }
105
106
    /**
107
     * @return string
108
     */
109 2
    public function getResponseClassName()
110
    {
111 2
        return AddOrderResponse::class;
112
    }
113
}
114