Role   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 45
ccs 10
cts 11
cp 0.9091
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B className() 0 15 5
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Model;
13
14
use Illuminate\Database\Eloquent\Collection;
15
use Illuminate\Database\Eloquent\Model;
16
17
/**
18
 * Role is model class for roles.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @property int $id
23
 * @property string $name
24
 * @property string $role
25
 * @property string $description
26
 * @property Collection $users
27
 * @property Collection $projectUsers
28
 * @property Collection $permissions
29
 */
30
class Role extends Model
31
{
32
    use Traits\Role\QueryTrait,
33
        Traits\Role\RelationTrait;
34
35
    const ROLE_USER      = 'user';
36
    const ROLE_DEVELOPER = 'developer';
37
    const ROLE_MANAGER   = 'manager';
38
    const ROLE_ADMIN     = 'administrator';
39
40
    /**
41
     * Timestamp enabled.
42
     *
43
     * @var bool
44
     */
45
    public $timestamps = false;
46
47
    /**
48
     * Name of database table.
49
     *
50
     * @var string
51
     */
52
    protected $table = 'roles';
53
54
    /**
55
     * Returns a class name based on role type.
56
     *
57
     * @return string
58
     */
59 4
    public function className()
60
    {
61 4
        switch (strtolower($this->name)) {
62 4
            case self::ROLE_USER:
63 1
                return 'tag';
64 4
            case self::ROLE_MANAGER:
65 1
                return 'success';
66 4
            case self::ROLE_DEVELOPER:
67 4
                return 'info';
68 1
            case self::ROLE_ADMIN:
69 1
                return 'primary';
70
        }
71
72
        return 'primary';
73
    }
74
}
75