1 | <?php |
||||
2 | |||||
3 | namespace Insenseanalytics\NovaBarMetrics; |
||||
4 | |||||
5 | use Illuminate\Support\Facades\DB; |
||||
0 ignored issues
–
show
|
|||||
6 | use Illuminate\Database\Eloquent\Builder; |
||||
0 ignored issues
–
show
The type
Illuminate\Database\Eloquent\Builder was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
7 | |||||
8 | /** |
||||
9 | * Use only with partition metrics or metrics derived from the Partition class |
||||
10 | * like BarChartMetric. |
||||
11 | */ |
||||
12 | trait HasFrequencyDistributions |
||||
13 | { |
||||
14 | /** |
||||
15 | * Return a partition/derived result showing the segments of a frequency range. |
||||
16 | * |
||||
17 | * @param \Illuminate\Http\Request $request |
||||
0 ignored issues
–
show
The type
Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
18 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||||
19 | * @param string $column |
||||
20 | * @param int $stepSize |
||||
21 | * |
||||
22 | * @return \Laravel\Nova\Metrics\PartitionResult |
||||
0 ignored issues
–
show
The type
Laravel\Nova\Metrics\PartitionResult was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
23 | */ |
||||
24 | public function distributions($request, $model, $column, $stepSize) |
||||
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
25 | { |
||||
26 | $subQuery = $model instanceof Builder ? $model : (new $model())->newQuery(); |
||||
27 | |||||
28 | $expression = FrequencyDistributionExpressionFactory::make( |
||||
29 | $subQuery, |
||||
30 | $column, |
||||
31 | $stepSize |
||||
32 | )->getValue(); |
||||
33 | |||||
34 | $subQuery = $subQuery |
||||
35 | ->select(DB::raw("{$expression['range']} as rng, |
||||
36 | {$expression['minVal']} as minval, count(*) as aggregate")) |
||||
37 | ->groupBy(DB::raw('1'), DB::raw('2')); |
||||
38 | |||||
39 | $query = DB::table(DB::raw("({$subQuery->toSql()}) as sub")) |
||||
40 | ->mergeBindings($subQuery->getQuery()); |
||||
41 | |||||
42 | $results = $query |
||||
43 | ->select('rng', 'aggregate', 'minval') |
||||
44 | ->orderBy('minval', 'asc') |
||||
45 | ->get(); |
||||
46 | |||||
47 | return $this->result($results->mapWithKeys(function ($result) use ($column) { |
||||
0 ignored issues
–
show
It seems like
result() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
48 | return $this->formatAggregateResult($result, 'rng'); |
||||
0 ignored issues
–
show
It seems like
formatAggregateResult() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
49 | })->all()); |
||||
50 | } |
||||
51 | |||||
52 | /** |
||||
53 | * Return a partition/derived result showing the segments of a frequency range. |
||||
54 | * |
||||
55 | * @param \Illuminate\Http\Request $request |
||||
56 | * @param \Illuminate\Database\Eloquent\Builder|string $model |
||||
57 | * @param string $column |
||||
58 | * @param int $maxSteps |
||||
59 | * |
||||
60 | * @return \Laravel\Nova\Metrics\PartitionResult |
||||
61 | */ |
||||
62 | public function distributionsWithSteps($request, $model, $column, $maxSteps = 15) |
||||
63 | { |
||||
64 | $query = $model instanceof Builder ? $model : (new $model())->newQuery(); |
||||
65 | |||||
66 | $difference = $query->max($column) - $query->min($column); |
||||
67 | |||||
68 | if (!$difference) { |
||||
69 | $stepSize = 1; |
||||
70 | } else { |
||||
71 | $stepSize = round($difference / $maxSteps, 0); |
||||
72 | } |
||||
73 | |||||
74 | return $this->distributions($request, $query, $column, $stepSize); |
||||
0 ignored issues
–
show
It seems like
$stepSize can also be of type double ; however, parameter $stepSize of Insenseanalytics\NovaBar...utions::distributions() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
75 | } |
||||
76 | } |
||||
77 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths