AdminMethodsEdit   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A edit() 0 9 1
1
<?php
2
3
namespace Larrock\Core\Traits;
4
5
use View;
6
use JsValidator;
0 ignored issues
show
Bug introduced by
The type JsValidator 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...
7
use Larrock\Core\Component;
8
9
trait AdminMethodsEdit
10
{
11
    /** @var Component */
12
    protected $config;
13
14
    /**
15
     * Show the form for editing the specified resource.
16
     * @param  int $id
17
     * @return View
18
     */
19
    public function edit($id)
20
    {
21
        $data['data'] = $this->config->getModel()::findOrFail($id);
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['app'] = $this->config->tabbable($data['data']);
23
24
        $validator = JsValidator::make($this->config->getValid($id));
25
        View::share('validator', $validator);
0 ignored issues
show
Bug introduced by
'validator' of type string is incompatible with the type array expected by parameter $| of Illuminate\Support\Facades\View::share(). ( Ignorable by Annotation )

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

25
        View::share(/** @scrutinizer ignore-type */ 'validator', $validator);
Loading history...
26
27
        return view('larrock::admin.admin-builder.edit', $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

27
        return /** @scrutinizer ignore-call */ view('larrock::admin.admin-builder.edit', $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...n-builder.edit', $data) returns the type array<string,mixed> which is incompatible with the documented return type View.
Loading history...
28
    }
29
}
30