AdminMethodsIndex   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 2 Features 1
Metric Value
eloc 12
c 2
b 2
f 1
dl 0
loc 27
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 17 3
1
<?php
2
3
namespace Larrock\Core\Traits;
4
5
use LarrockCategory;
0 ignored issues
show
Bug introduced by
The type LarrockCategory 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Larrock\Core\Component;
7
8
trait AdminMethodsIndex
9
{
10
    /** @var Component */
11
    protected $config;
12
13
    /**
14
     * Display a listing of the resource.
15
     *
16
     * @return \View
17
     */
18
    public function index()
19
    {
20
        if (isset($this->config->rows['category'])) {
21
            $data['app_category'] = LarrockCategory::getConfig();
0 ignored issues
show
Comprehensibility Best Practice introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.
Loading history...
22
            $data['categories'] = LarrockCategory::getModel()->whereComponent($this->config->name)->whereLevel(1)
23
                ->orderBy('position', 'DESC')->orderBy('updated_at', 'ASC')->with(['getChild', 'getParent'])->paginate(30);
24
25
            return view('larrock::admin.admin-builder.categories', $data);
0 ignored issues
show
Unused Code introduced by
The call to view() has too many arguments starting with $data. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            return /** @scrutinizer ignore-call */ view('larrock::admin.admin-builder.categories', $data);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug Best Practice introduced by
The expression return view('larrock::ad...der.categories', $data) returns the type array<string,mixed> which is incompatible with the documented return type View.
Loading history...
26
        }
27
28
        if (array_key_exists('position', $this->config->rows)) {
29
            $data['data'] = $this->config->getModel()::orderBy('position', 'DESC')->paginate(30);
30
        } else {
31
            $data['data'] = $this->config->getModel()::paginate(30);
32
        }
33
34
        return view('larrock::admin.admin-builder.index', $data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('larrock::ad...-builder.index', $data) returns the type array<string,mixed> which is incompatible with the documented return type View.
Loading history...
35
    }
36
}
37