1 | <?php namespace Arcanedev\LaravelMetrics\Metrics; |
||
12 | abstract class Partition extends Metric |
||
13 | { |
||
14 | /* ----------------------------------------------------------------- |
||
15 | | Getters |
||
16 | | ----------------------------------------------------------------- |
||
17 | */ |
||
18 | |||
19 | /** |
||
20 | * Get the metric type. |
||
21 | * |
||
22 | * @return string |
||
23 | */ |
||
24 | 28 | public function type(): string |
|
28 | |||
29 | /* ----------------------------------------------------------------- |
||
30 | | Main Methods |
||
31 | | ----------------------------------------------------------------- |
||
32 | */ |
||
33 | |||
34 | /** |
||
35 | * Calculate the `count` of the metric. |
||
36 | * |
||
37 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
38 | * @param string $groupBy |
||
39 | * @param string|null $column |
||
40 | * |
||
41 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
42 | */ |
||
43 | 12 | public function count($model, string $groupBy, $column = null) |
|
47 | |||
48 | /** |
||
49 | * Calculate the `average` of the metric. |
||
50 | * |
||
51 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
52 | * @param string $column |
||
53 | * @param string $groupBy |
||
54 | * |
||
55 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
56 | */ |
||
57 | 4 | public function average($model, string $column, string $groupBy) |
|
61 | |||
62 | /** |
||
63 | * Calculate the `sum` of the metric. |
||
64 | * |
||
65 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
66 | * @param string $column |
||
67 | * @param string $groupBy |
||
68 | * |
||
69 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
70 | */ |
||
71 | 4 | public function sum($model, string $column, string $groupBy) |
|
75 | |||
76 | /** |
||
77 | * Calculate the `max` of the metric. |
||
78 | * |
||
79 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
80 | * @param string $column |
||
81 | * @param string $groupBy |
||
82 | * |
||
83 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
84 | */ |
||
85 | 4 | public function max($model, string $column, string $groupBy) |
|
89 | |||
90 | /** |
||
91 | * Calculate the `min` of the metric. |
||
92 | * |
||
93 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
94 | * @param string $column |
||
95 | * @param string $groupBy |
||
96 | * |
||
97 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
98 | */ |
||
99 | 4 | public function min($model, string $column, string $groupBy) |
|
103 | |||
104 | /* ----------------------------------------------------------------- |
||
105 | | Other Methods |
||
106 | | ----------------------------------------------------------------- |
||
107 | */ |
||
108 | |||
109 | /** |
||
110 | * Handle the aggregate calculation of the metric. |
||
111 | * |
||
112 | * @param string $method |
||
113 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
114 | * @param string $column |
||
115 | * @param string $groupBy |
||
116 | * |
||
117 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
118 | */ |
||
119 | 28 | protected function aggregate($method, $model, $column, $groupBy) |
|
138 | |||
139 | /** |
||
140 | * Format the aggregate result for the partition. |
||
141 | * |
||
142 | * @param \Illuminate\Database\Eloquent\Model $result |
||
143 | * @param string $groupBy |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | 28 | protected function formatAggregateResult($result, $groupBy): array |
|
155 | |||
156 | /** |
||
157 | * Make a new result instance. |
||
158 | * |
||
159 | * @param mixed|null $value |
||
160 | * |
||
161 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
162 | */ |
||
163 | 28 | protected function result($value = null) |
|
167 | } |
||
168 |
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: