TickerModel::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 22
ccs 11
cts 11
cp 1
crap 1
rs 9.2
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
 * @author  Fabian Hanisch
4
 * @since   17.07.2017 20:34
5
 * @version 1.0
6
 */
7
8
namespace HanischIt\KrakenApi\Call\GetTicker\Model;
9
10
/**
11
 * Class TickerModel
12
 * @package HanischIt\KrakenApi\Call\GetTicker\Model
13
 */
14
class TickerModel
15
{
16
    /**
17
     * @var string
18
     */
19
    private $assetPair;
20
    /**
21
     * @var AskBidModel
22
     */
23
    private $ask;
24
    /**
25
     * @var AskBidModel
26
     */
27
    private $bid;
28
    /**
29
     * @var
30
     */
31
    private $lastTradeClosed;
32
    /**
33
     * @var DayPriceModel
34
     */
35
    private $volume;
36
    /**
37
     * @var DayPriceModel
38
     */
39
    private $volumeWeightedAverage;
40
    /**
41
     * @var DayPriceModel
42
     */
43
    private $numberOfTrades;
44
    /**
45
     * @var DayPriceModel
46
     */
47
    private $low;
48
    /**
49
     * @var DayPriceModel
50
     */
51
    private $high;
52
    /**
53
     * @var float
54
     */
55
    private $todaysOpeningPrice;
56
57
    /**
58
     * TickerModel constructor.
59
     *
60
     * @param string $assetPair
61
     * @param AskBidModel $ask
62
     * @param AskBidModel $bid
63
     * @param PriceVolumeModel $lastTradeClosed
64
     * @param DayPriceModel $volume
65
     * @param DayPriceModel $volumeWeightedAverage
66
     * @param DayPriceModel $numberOfTrades
67
     * @param DayPriceModel $low
68
     * @param DayPriceModel $high
69
     * @param float $todaysOpeningPrice
70
     */
71 2
    public function __construct(
72
        $assetPair,
73
        AskBidModel $ask,
74
        AskBidModel $bid,
75
        PriceVolumeModel $lastTradeClosed,
76
        DayPriceModel $volume,
77
        DayPriceModel $volumeWeightedAverage,
78
        DayPriceModel $numberOfTrades,
79
        DayPriceModel $low,
80
        DayPriceModel $high,
81
        $todaysOpeningPrice
82
    ) {
83 2
        $this->assetPair = $assetPair;
84 2
        $this->ask = $ask;
85 2
        $this->bid = $bid;
86 2
        $this->lastTradeClosed = $lastTradeClosed;
87 2
        $this->volume = $volume;
88 2
        $this->volumeWeightedAverage = $volumeWeightedAverage;
89 2
        $this->numberOfTrades = $numberOfTrades;
90 2
        $this->low = $low;
91 2
        $this->high = $high;
92 2
        $this->todaysOpeningPrice = $todaysOpeningPrice;
93 2
    }
94
95
    /**
96
     * @return AskBidModel
97
     */
98 1
    public function getAsk()
99
    {
100 1
        return $this->ask;
101
    }
102
103
    /**
104
     * @return AskBidModel
105
     */
106 1
    public function getBid()
107
    {
108 1
        return $this->bid;
109
    }
110
111
    /**
112
     * @return mixed
113
     */
114 1
    public function getLastTradeClosed()
115
    {
116 1
        return $this->lastTradeClosed;
117
    }
118
119
    /**
120
     * @return DayPriceModel
121
     */
122 1
    public function getVolume()
123
    {
124 1
        return $this->volume;
125
    }
126
127
    /**
128
     * @return DayPriceModel
129
     */
130 1
    public function getVolumeWeightedAverage()
131
    {
132 1
        return $this->volumeWeightedAverage;
133
    }
134
135
    /**
136
     * @return DayPriceModel
137
     */
138 1
    public function getNumberOfTrades()
139
    {
140 1
        return $this->numberOfTrades;
141
    }
142
143
    /**
144
     * @return DayPriceModel
145
     */
146 1
    public function getLow()
147
    {
148 1
        return $this->low;
149
    }
150
151
    /**
152
     * @return DayPriceModel
153
     */
154 1
    public function getHigh()
155
    {
156 1
        return $this->high;
157
    }
158
159
    /**
160
     * @return float
161
     */
162 1
    public function getTodaysOpeningPrice()
163
    {
164 1
        return $this->todaysOpeningPrice;
165
    }
166
}
167