1 | <?php |
||
16 | abstract class NullablePartition extends Metric |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Traits |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | use HasExpressions; |
||
24 | |||
25 | /* ----------------------------------------------------------------- |
||
26 | | Getters |
||
27 | | ----------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * Get the metric's type. |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | 4 | public function type(): string |
|
39 | |||
40 | /* ----------------------------------------------------------------- |
||
41 | | Main Methods |
||
42 | | ----------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | /** |
||
46 | * Calculate the `count` of the metric. |
||
47 | * |
||
48 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
49 | * @param string $groupBy |
||
50 | * @param string|null $column |
||
51 | * |
||
52 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
53 | */ |
||
54 | 4 | protected function count($model, string $groupBy, $column = null) |
|
58 | |||
59 | /* ----------------------------------------------------------------- |
||
60 | | Other Methods |
||
61 | | ----------------------------------------------------------------- |
||
62 | */ |
||
63 | |||
64 | /** |
||
65 | * Handle the aggregate calculation of the metric. |
||
66 | * |
||
67 | * @param string $method |
||
68 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
69 | * @param string $column |
||
70 | * @param string $groupBy |
||
71 | * |
||
72 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
73 | */ |
||
74 | 4 | protected function aggregate(string $method, $model, ?string $column, string $groupBy) |
|
97 | |||
98 | /** |
||
99 | * Format the aggregate result for the partition. |
||
100 | * |
||
101 | * @param \Illuminate\Database\Eloquent\Model $result |
||
102 | * @param string $groupBy |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 4 | protected function formatAggregateResult($result, $groupBy): array |
|
114 | |||
115 | /** |
||
116 | * Make a new result instance. |
||
117 | * |
||
118 | * @param mixed|null $value |
||
119 | * |
||
120 | * @return \Arcanedev\LaravelMetrics\Results\PartitionResult|mixed |
||
121 | */ |
||
122 | 4 | protected function result($value = null) |
|
126 | } |
||
127 |
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: