LaravelNovaPermission   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 71
rs 10
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A roleResource() 0 5 1
A permissionResource() 0 5 1
A renderNavigation() 0 3 1
A boot() 0 7 4
A withRegistration() 0 5 1
1
<?php
2
3
namespace Insenseanalytics\LaravelNovaPermission;
4
5
use Laravel\Nova\Tool;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Tool 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 Laravel\Nova\Nova;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Nova 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
8
class LaravelNovaPermission extends Tool
9
{
10
	public $roleResource = Role::class;
11
	public $permissionResource = Permission::class;
12
13
	public $registerCustomResources = false;
14
15
	/**
16
	 * Perform any tasks that need to happen when the tool is booted.
17
	 */
18
	public function boot()
19
	{
20
		if ((Role::class === $this->roleResource && Permission::class === $this->permissionResource)
21
			|| $this->registerCustomResources) {
22
			Nova::resources([
23
				$this->roleResource,
24
				$this->permissionResource,
25
			]);
26
		}
27
	}
28
29
	/**
30
	 * Set a custom Role resource class.
31
	 *
32
	 * @param Role resource class
33
	 *
34
	 * @return $this
35
	 */
36
	public function roleResource(string $roleResource)
37
	{
38
		$this->roleResource = $roleResource;
39
40
		return $this;
41
	}
42
43
	/**
44
	 * Set a custom Permission resource class.
45
	 *
46
	 * @param Permission resource class
47
	 *
48
	 * @return $this
49
	 */
50
	public function permissionResource(string $permissionResource)
51
	{
52
		$this->permissionResource = $permissionResource;
53
54
		return $this;
55
	}
56
57
	/**
58
	 * Register the custom resource classes.
59
	 *
60
	 * @param bool
61
	 *
62
	 * @return $this
63
	 */
64
	public function withRegistration()
65
	{
66
		$this->registerCustomResources = true;
67
68
		return $this;
69
	}
70
71
	/**
72
	 * Build the view that renders the navigation links for the tool.
73
	 *
74
	 * @return \Illuminate\View\View
0 ignored issues
show
Bug introduced by
The type Illuminate\View\View 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...
75
	 */
76
	public function renderNavigation()
77
	{
78
		return view('laravel-nova-permission::navigation');
0 ignored issues
show
Bug introduced by
The function view 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

78
		return /** @scrutinizer ignore-call */ view('laravel-nova-permission::navigation');
Loading history...
79
	}
80
}
81