1 | <?php namespace Arcanedev\LaravelMetrics\Results; |
||
9 | class RangedValueResult extends ValueResult |
||
10 | { |
||
11 | /* ----------------------------------------------------------------- |
||
12 | | Properties |
||
13 | | ----------------------------------------------------------------- |
||
14 | */ |
||
15 | |||
16 | /** |
||
17 | * The previous property. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | public $previous = [ |
||
22 | 'value' => null, |
||
23 | 'label' => null, |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * The change property. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | public $change = [ |
||
32 | 'value' => null, |
||
33 | 'label' => null, |
||
34 | ]; |
||
35 | |||
36 | /* ----------------------------------------------------------------- |
||
37 | | Getters & Setters |
||
38 | | ----------------------------------------------------------------- |
||
39 | */ |
||
40 | |||
41 | /** |
||
42 | * Set the value. |
||
43 | * |
||
44 | * @param mixed $value |
||
45 | * |
||
46 | * @return $this |
||
47 | */ |
||
48 | 52 | public function value($value) |
|
54 | |||
55 | /** |
||
56 | * Set the previous property. |
||
57 | * |
||
58 | * @param mixed $value |
||
59 | * @param string|null $label |
||
60 | * |
||
61 | * @return $this |
||
62 | */ |
||
63 | 32 | public function previous($value, $label = null) |
|
69 | |||
70 | /** |
||
71 | * Set the change property. |
||
72 | * |
||
73 | * @param mixed $value |
||
74 | * @param string|null $label |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | 52 | public function change($value, $label = null) |
|
84 | |||
85 | /* ----------------------------------------------------------------- |
||
86 | | Other Methods |
||
87 | | ----------------------------------------------------------------- |
||
88 | */ |
||
89 | |||
90 | /** |
||
91 | * Update the change property. |
||
92 | * |
||
93 | * @return $this |
||
94 | */ |
||
95 | 52 | protected function updateChange() |
|
111 | |||
112 | /** |
||
113 | * Get the instance as an array. |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | 16 | public function toArray(): array |
|
124 | |||
125 | /** |
||
126 | * Calculate the change. |
||
127 | * |
||
128 | * @param float|int $current |
||
129 | * @param float|int $previous |
||
130 | * |
||
131 | * @return float|int |
||
132 | */ |
||
133 | 32 | protected static function calculateChange($current, $previous) |
|
144 | } |
||
145 |