BatchSkeleton::route()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Terranet\Administrator\Traits\Actions;
4
5
use Illuminate\Contracts\Auth\Authenticatable as User;
6
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Model 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 Illuminate\Support\Str;
8
use Terranet\Administrator\Contracts\Module;
9
10
trait BatchSkeleton
11
{
12
    /**
13
     * Check if specified user is authorized to execute this action.
14
     *
15
     * @param User $viewer
16
     * @param null|Model $model
17
     *
18
     * @return bool
19
     */
20
    public function authorize(User $viewer, ?Model $model = null)
0 ignored issues
show
Unused Code introduced by
The parameter $viewer 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 ignore-unused  annotation

20
    public function authorize(/** @scrutinizer ignore-unused */ User $viewer, ?Model $model = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
    {
22
        /** @var Module $resource */
23
        $resource = app('scaffold.module');
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

23
        $resource = /** @scrutinizer ignore-call */ app('scaffold.module');
Loading history...
24
25
        return $resource->actions()->authorize(
26
            Str::snake(class_basename($this)),
27
            $model
28
        );
29
    }
30
31
    /**
32
     * @param $model
33
     *
34
     * @return string
35
     */
36
    protected function route($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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 ignore-unused  annotation

36
    protected function route(/** @scrutinizer ignore-unused */ $model)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
        return route('scaffold.batch', ['module' => app('scaffold.module')->url()]);
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

38
        return /** @scrutinizer ignore-call */ route('scaffold.batch', ['module' => app('scaffold.module')->url()]);
Loading history...
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

38
        return route('scaffold.batch', ['module' => /** @scrutinizer ignore-call */ app('scaffold.module')->url()]);
Loading history...
39
    }
40
41
    /**
42
     * @param $model
43
     *
44
     * @return string
45
     */
46
    protected function attributes($model)
47
    {
48
        return \admin\helpers\html_attributes([
49
            'data-confirmation' => sprintf('Are you sure you want to %s?', $this->name($model)),
0 ignored issues
show
Bug introduced by
It seems like name() 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 ignore-call  annotation

49
            'data-confirmation' => sprintf('Are you sure you want to %s?', $this->/** @scrutinizer ignore-call */ name($model)),
Loading history...
50
            'data-action' => $this->action($model),
0 ignored issues
show
Bug introduced by
It seems like action() 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 ignore-call  annotation

50
            'data-action' => $this->/** @scrutinizer ignore-call */ action($model),
Loading history...
51
            'class' => 'text-left',
52
        ]);
53
    }
54
}
55