1 | <?php |
||
15 | abstract class Value extends Metric |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Traits |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | use HasRoundedValue; |
||
23 | |||
24 | /* ----------------------------------------------------------------- |
||
25 | | Getters & Setters |
||
26 | | ----------------------------------------------------------------- |
||
27 | */ |
||
28 | |||
29 | /** |
||
30 | * Get the metric type. |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | 36 | public function type(): string |
|
38 | |||
39 | /* ----------------------------------------------------------------- |
||
40 | | Main Methods |
||
41 | | ----------------------------------------------------------------- |
||
42 | */ |
||
43 | |||
44 | /** |
||
45 | * Calculate the `count` of the metric. |
||
46 | * |
||
47 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
48 | * @param string|string $column |
||
49 | * |
||
50 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
51 | */ |
||
52 | 4 | public function count($model, $column = null) |
|
56 | |||
57 | /** |
||
58 | * Calculate the `average` of the metric. |
||
59 | * |
||
60 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
61 | * @param string $column |
||
62 | * |
||
63 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
64 | */ |
||
65 | 12 | public function average($model, string $column) |
|
69 | |||
70 | /** |
||
71 | * Calculate the `sum` of the metric. |
||
72 | * |
||
73 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
74 | * @param string $column |
||
75 | * |
||
76 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
77 | */ |
||
78 | 4 | public function sum($model, string $column) |
|
82 | |||
83 | /** |
||
84 | * Calculate the `max` of the metric. |
||
85 | * |
||
86 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
87 | * @param string $column |
||
88 | * |
||
89 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
90 | */ |
||
91 | 4 | public function max($model, string $column) |
|
95 | |||
96 | /** |
||
97 | * Calculate the `min` of the metric. |
||
98 | * |
||
99 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
100 | * @param string $column |
||
101 | * |
||
102 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
103 | */ |
||
104 | 4 | public function min($model, string $column) |
|
108 | |||
109 | /* ----------------------------------------------------------------- |
||
110 | | Other Methods |
||
111 | | ----------------------------------------------------------------- |
||
112 | */ |
||
113 | |||
114 | /** |
||
115 | * Handle the aggregate calculation of the metric. |
||
116 | * |
||
117 | * @param string $method |
||
118 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||
119 | * @param string|null $column |
||
120 | * |
||
121 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
122 | */ |
||
123 | 28 | protected function aggregate(string $method, $model, string $column = null) |
|
132 | |||
133 | /** |
||
134 | * Make a new result instance. |
||
135 | * |
||
136 | * @param mixed|null $value |
||
137 | * |
||
138 | * @return \Arcanedev\LaravelMetrics\Results\ValueResult|mixed |
||
139 | */ |
||
140 | 28 | protected function result($value = null) |
|
144 | } |
||
145 |
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: