1 | <?php |
||
19 | abstract class Trend extends Metric |
||
20 | { |
||
21 | /* ----------------------------------------------------------------- |
||
22 | | Constants |
||
23 | | ----------------------------------------------------------------- |
||
24 | */ |
||
25 | |||
26 | /** |
||
27 | * Trend metric unit constants. |
||
28 | */ |
||
29 | const BY_MONTHS = 'month'; |
||
30 | const BY_WEEKS = 'week'; |
||
31 | const BY_DAYS = 'day'; |
||
32 | const BY_HOURS = 'hour'; |
||
33 | const BY_MINUTES = 'minute'; |
||
34 | |||
35 | /* ----------------------------------------------------------------- |
||
36 | | Traits |
||
37 | | ----------------------------------------------------------------- |
||
38 | */ |
||
39 | |||
40 | use Concerns\AggregatesTrends, |
||
41 | Concerns\HasExpressions, |
||
42 | Concerns\HasRanges, |
||
43 | Concerns\FormatsTrends; |
||
44 | |||
45 | /* ----------------------------------------------------------------- |
||
46 | | Getters |
||
47 | | ----------------------------------------------------------------- |
||
48 | */ |
||
49 | |||
50 | /** |
||
51 | * Get the metric type. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | 36 | public function type(): string |
|
59 | |||
60 | /* ----------------------------------------------------------------- |
||
61 | | Main Methods |
||
62 | | ----------------------------------------------------------------- |
||
63 | */ |
||
64 | |||
65 | /** |
||
66 | * Calculate the `count` of the metric. |
||
67 | * |
||
68 | * @param string $unit |
||
69 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
70 | * @param string|null $dateColumn |
||
71 | * @param string|null $column |
||
72 | * |
||
73 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
74 | */ |
||
75 | 30 | public function count($unit, $model, $dateColumn = null, $column = null) |
|
79 | |||
80 | /** |
||
81 | * Return a value result showing a average aggregate over time. |
||
82 | * |
||
83 | * @param string $unit |
||
84 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
85 | * @param string $column |
||
86 | * @param string|null $dateColumn |
||
87 | * |
||
88 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
89 | */ |
||
90 | public function average(string $unit, $model, $column, $dateColumn = null) |
||
94 | |||
95 | /** |
||
96 | * Return a value result showing a sum aggregate over time. |
||
97 | * |
||
98 | * @param string $unit |
||
99 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
100 | * @param string $column |
||
101 | * @param string|null $dateColumn |
||
102 | * |
||
103 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
104 | */ |
||
105 | public function sum(string $unit, $model, $column, $dateColumn = null) |
||
109 | |||
110 | /** |
||
111 | * Return a value result showing a max aggregate over time. |
||
112 | * |
||
113 | * @param string $unit |
||
114 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
115 | * @param string $column |
||
116 | * @param string|null $dateColumn |
||
117 | * |
||
118 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
119 | */ |
||
120 | public function max(string $unit, $model, $column, $dateColumn = null) |
||
124 | |||
125 | /** |
||
126 | * Return a value result showing a min aggregate over time. |
||
127 | * |
||
128 | * @param string $unit |
||
129 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
130 | * @param string $column |
||
131 | * @param string|null $dateColumn |
||
132 | * |
||
133 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
134 | */ |
||
135 | public function min(string $unit, $model, $column, $dateColumn = null) |
||
139 | |||
140 | /** |
||
141 | * Make a new result instance. |
||
142 | * |
||
143 | * @param mixed|null $value |
||
144 | * |
||
145 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
146 | */ |
||
147 | 30 | protected function result($value = null) |
|
151 | |||
152 | /* ----------------------------------------------------------------- |
||
153 | | Other Methods |
||
154 | | ----------------------------------------------------------------- |
||
155 | */ |
||
156 | |||
157 | /** |
||
158 | * Handle the aggregate calculation of the metric. |
||
159 | * |
||
160 | * @param string $method |
||
161 | * @param string $unit |
||
162 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
163 | * @param string|null $column |
||
164 | * @param string|null $dateColumn |
||
165 | * |
||
166 | * @return \Arcanedev\LaravelMetrics\Results\TrendResult|mixed |
||
167 | */ |
||
168 | 30 | protected function aggregate(string $method, string $unit, $model, ?string $column = null, ?string $dateColumn = null) |
|
222 | |||
223 | /** |
||
224 | * Parse the date result. |
||
225 | * |
||
226 | * @param string $date |
||
227 | * @param string $unit |
||
228 | * |
||
229 | * @return \Cake\Chronos\Chronos |
||
230 | */ |
||
231 | 30 | protected function parseDateResult(string $date, string $unit): Chronos |
|
255 | |||
256 | /** |
||
257 | * Get the instance as an array. |
||
258 | * |
||
259 | * @return array |
||
260 | */ |
||
261 | 6 | public function toArray(): array |
|
268 | } |
||
269 |
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: