1 | <?php namespace Arcanedev\LaravelMetrics\Metrics; |
||
15 | abstract class Trend extends Metric |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Constants |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Trend metric unit constants. |
||
24 | */ |
||
25 | const BY_MONTHS = 'month'; |
||
26 | const BY_WEEKS = 'week'; |
||
27 | const BY_DAYS = 'day'; |
||
28 | const BY_HOURS = 'hour'; |
||
29 | const BY_MINUTES = 'minute'; |
||
30 | |||
31 | /* ----------------------------------------------------------------- |
||
32 | | Traits |
||
33 | | ----------------------------------------------------------------- |
||
34 | */ |
||
35 | |||
36 | use Concerns\AggregatesTrends, |
||
37 | Concerns\HasExpressions, |
||
38 | Concerns\HasRanges, |
||
39 | Concerns\FormatsTrends; |
||
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Getters |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | |||
46 | /** |
||
47 | * Get the metric type. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 12 | public function type(): string |
|
55 | |||
56 | /* ----------------------------------------------------------------- |
||
57 | | Main Methods |
||
58 | | ----------------------------------------------------------------- |
||
59 | */ |
||
60 | |||
61 | /** |
||
62 | * Calculate the `count` of the metric. |
||
63 | * |
||
64 | * @param string $unit |
||
65 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
66 | * @param string|null $dateColumn |
||
67 | * @param string|null $column |
||
68 | * |
||
69 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
70 | */ |
||
71 | 10 | public function count($unit, $model, $dateColumn = null, $column = null) |
|
75 | |||
76 | /** |
||
77 | * Return a value result showing a average aggregate over time. |
||
78 | * |
||
79 | * @param string $unit |
||
80 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
81 | * @param string $column |
||
82 | * @param string|null $dateColumn |
||
83 | * |
||
84 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
85 | */ |
||
86 | public function average(string $unit, $model, $column, $dateColumn = null) |
||
90 | |||
91 | /** |
||
92 | * Return a value result showing a sum aggregate over time. |
||
93 | * |
||
94 | * @param string $unit |
||
95 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
96 | * @param string $column |
||
97 | * @param string|null $dateColumn |
||
98 | * |
||
99 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
100 | */ |
||
101 | public function sum(string $unit, $model, $column, $dateColumn = null) |
||
105 | |||
106 | /** |
||
107 | * Return a value result showing a max aggregate over time. |
||
108 | * |
||
109 | * @param string $unit |
||
110 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
111 | * @param string $column |
||
112 | * @param string|null $dateColumn |
||
113 | * |
||
114 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
115 | */ |
||
116 | public function max(string $unit, $model, $column, $dateColumn = null) |
||
120 | |||
121 | /** |
||
122 | * Return a value result showing a min aggregate over time. |
||
123 | * |
||
124 | * @param string $unit |
||
125 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
126 | * @param string $column |
||
127 | * @param string|null $dateColumn |
||
128 | * |
||
129 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
130 | */ |
||
131 | public function min(string $unit, $model, $column, $dateColumn = null) |
||
135 | |||
136 | /** |
||
137 | * Make a new result instance. |
||
138 | * |
||
139 | * @param mixed|null $value |
||
140 | * |
||
141 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
142 | */ |
||
143 | 10 | protected function result($value = null) |
|
147 | |||
148 | /* ----------------------------------------------------------------- |
||
149 | | Other Methods |
||
150 | | ----------------------------------------------------------------- |
||
151 | */ |
||
152 | |||
153 | /** |
||
154 | * Handle the aggregate calculation of the metric. |
||
155 | * |
||
156 | * @param string $method |
||
157 | * @param string $unit |
||
158 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
159 | * @param string|null $column |
||
160 | * @param string|null $dateColumn |
||
161 | * |
||
162 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
163 | */ |
||
164 | 10 | protected function aggregate(string $method, string $unit, $model, ?string $column = null, ?string $dateColumn = null) |
|
218 | |||
219 | /** |
||
220 | * Parse the date result. |
||
221 | * |
||
222 | * @param string $date |
||
223 | * @param string $unit |
||
224 | * |
||
225 | * @return \Cake\Chronos\Chronos |
||
226 | */ |
||
227 | 10 | protected function parseDateResult(string $date, string $unit): Chronos |
|
250 | |||
251 | /** |
||
252 | * Get the instance as an array. |
||
253 | * |
||
254 | * @return array |
||
255 | */ |
||
256 | 2 | public function toArray(): array |
|
263 | } |
||
264 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: