Passed
Pull Request — master (#1558)
by Darko
12:16 queued 04:35
created

CategoryPolicy   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

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

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A manageThreads() 0 3 1
A edit() 0 3 1
A restoreThreads() 0 3 1
A enableThreads() 0 3 1
A moveThreadsTo() 0 3 1
A deleteThreads() 0 3 1
A delete() 0 3 1
A moveThreadsFrom() 0 3 1
A view() 0 3 1
A pinThreads() 0 3 1
A lockThreads() 0 3 1
1
<?php
2
3
namespace App\Policies;
4
5
use Illuminate\Foundation\Auth\User;
6
use TeamTeaTime\Forum\Models\Category;
7
8
class CategoryPolicy extends \TeamTeaTime\Forum\Policies\CategoryPolicy
9
{
10
    /**
11
     * Create a new policy instance.
12
     */
13
    public function __construct()
14
    {
15
        //
16
    }
17
18
    public function manageThreads($user, Category $category): bool
19
    {
20
        return $user->hasRole('Admin');
21
    }
22
23
    public function deleteThreads($user, Category $category): bool
24
    {
25
        return $user->hasRole('Admin');
26
    }
27
28
    public function restoreThreads($user, Category $category): bool
29
    {
30
        return $user->hasRole('Admin');
31
    }
32
33
    public function enableThreads($user, Category $category): bool
0 ignored issues
show
Unused Code introduced by
The parameter $category 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

33
    public function enableThreads($user, /** @scrutinizer ignore-unused */ Category $category): bool

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...
34
    {
35
        return $user->hasRole('Admin');
36
    }
37
38
    public function moveThreadsFrom($user, Category $category): bool
39
    {
40
        return $user->hasRole('Admin');
41
    }
42
43
    public function moveThreadsTo($user, Category $category): bool
44
    {
45
        return $user->hasRole('Admin');
46
    }
47
48
    public function lockThreads($user, Category $category): bool
49
    {
50
        return $user->hasRole('Admin');
51
    }
52
53
    public function pinThreads($user, Category $category): bool
54
    {
55
        return $user->hasRole('Admin');
56
    }
57
58
    public function view($user, Category $category): bool
59
    {
60
        return $user->hasAnyRole(['Admin', 'Moderator']);
61
    }
62
63
    public function delete($user, Category $category): bool
64
    {
65
        return $user->hasRole('Admin');
66
    }
67
68
    public function edit(User $user, Category $category): bool
69
    {
70
        return $user->hasRole('Admin');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $user->hasRole('Admin') could return the type Illuminate\Database\Eloq...gHasThroughRelationship which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
71
    }
72
}
73