DevicePolicy   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 79
Duplicated Lines 100 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 79
loc 79
ccs 0
cts 14
cp 0
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A edit() 3 3 1
A show() 3 3 1
A destroy() 3 3 1
A updateCommand() 3 3 1
A update() 3 3 1
A restore() 3 3 1
A index() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Policies;
4
5
use App\User;
6
use App\Device;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9 View Code Duplication
class DevicePolicy
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    use HandlesAuthorization;
12
13
    /**
14
     * Determine whether the user can view the list of devices.
15
     *
16
     * @param  \App\User  $user
17
     * @return mixed
18
     */
19
    public function index(User $user)
20
    {
21
        return $user->isManager();
22
    }
23
    
24
    /**
25
     * Determine whether the user can view a device.
26
     *
27
     * @param  \App\User  $user
28
     * @return mixed
29
     */
30
    public function show(User $user)
31
    {
32
        return $user->isUser();
33
    }
34
    
35
    /**
36
     * Determine whether the user can view the edit page for a device.
37
     *
38
     * @param  \App\User  $user
39
     * @return mixed
40
     */
41
    public function edit(User $user)
42
    {
43
        return $user->isManager();
44
    }
45
    
46
    /**
47
     * Determine whether the user can update the device.
48
     *
49
     * @param  \App\User  $user
50
     * @return mixed
51
     */
52
    public function update(User $user)
53
    {
54
        return $user->isManager();
55
    }
56
    
57
    /**
58
     * Determine whether the user can update the device's command.
59
     *
60
     * @param  \App\User  $user
61
     * @return mixed
62
     */
63
    public function updateCommand(User $user)
64
    {
65
        return $user->isUser();
66
    }
67
    
68
    /**
69
     * Determine whether the user can delete the device.
70
     *
71
     * @param  \App\User  $user
72
     * @return mixed
73
     */
74
    public function destroy(User $user)
75
    {
76
        return $user->isAdmin();
77
    }
78
    
79
    /**
80
     * Determine whether the user can restore the device.
81
     *
82
     * @param  \App\User  $user
83
     * @return mixed
84
     */
85
    public function restore(User $user)
86
    {
87
        return $user->isAdmin();
88
    }
89
}
90