Completed
Push — master ( 91f8d9...64265e )
by Mohamed
09:45 queued 06:57
created

Role   A

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 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
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\Model;
15
16
/**
17
 * Role is model class for roles.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 *
21
 * @property int $id
22
 * @property string $name
23
 * @property string $role
24
 * @property string $description
25
 */
26
class Role extends Model
27
{
28
    use Traits\Role\QueryTrait,
29
        Traits\Role\RelationTrait;
30
31
    const ROLE_USER      = 'user';
32
    const ROLE_DEVELOPER = 'developer';
33
    const ROLE_MANAGER   = 'manager';
34
    const ROLE_ADMIN     = 'administrator';
35
36
    /**
37
     * Timestamp enabled.
38
     *
39
     * @var bool
40
     */
41
    public $timestamps = false;
42
43
    /**
44
     * Name of database table.
45
     *
46
     * @var string
47
     */
48
    protected $table = 'roles';
49
50
    /**
51
     * Returns a class name based on role type.
52
     *
53
     * @return string
54
     */
55 4
    public function className()
56
    {
57 4
        switch (strtolower($this->name)) {
58 4
            case self::ROLE_USER:
59 1
                return 'tag';
60 4
            case self::ROLE_MANAGER:
61 1
                return 'success';
62 4
            case self::ROLE_DEVELOPER:
63 4
                return 'info';
64 1
            case self::ROLE_ADMIN:
65 1
                return 'primary';
66
        }
67
68
        return 'primary';
69
    }
70
}
71