RoleTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isUserOrMore() 0 3 1
A isOwner() 0 3 1
A isUser() 0 3 1
A isSuperAdmin() 0 3 1
A isAssociationPresident() 0 3 1
A isFederationPresident() 0 3 1
A isClubPresident() 0 3 1
1
<?php
2
3
namespace App\Traits;
4
5
trait RoleTrait
6
{
7
    /**
8
     * @return bool
9
     */
10 34
    public function isSuperAdmin()
11
    {
12 34
        return $this->role_id == config('constants.ROLE_SUPERADMIN');
13
    }
14
15
    /**
16
     * @return bool
17
     */
18 29
    public function isFederationPresident()
19
    {
20 29
        return $this->role_id == config('constants.ROLE_FEDERATION_PRESIDENT');
21
    }
22
23
    /**
24
     * @return bool
25
     */
26 29
    public function isAssociationPresident()
27
    {
28 29
        return $this->role_id == config('constants.ROLE_ASSOCIATION_PRESIDENT');
29
    }
30
31
    /**
32
     * @return bool
33
     */
34 28
    public function isClubPresident()
35
    {
36 28
        return $this->role_id == config('constants.ROLE_CLUB_PRESIDENT');
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    public function isUser()
43
    {
44
        return $this->role_id == config('constants.ROLE_USER');
45
    }
46
47
    /**
48
     * @return bool
49
     */
50 5
    public function isUserOrMore()
51
    {
52 5
        return $this->role_id <= config('constants.ROLE_USER');
53
    }
54
55
    /**
56
     * @param $tournament
57
     * @return bool
58
     */
59
    public function isOwner($tournament)
60
    {
61
        return $tournament->user_id == $this->id;
62
    }
63
}