Completed
Branch develop (a31570)
by Mohamed
08:09 queued 04:45
created

Role::className()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 11
cp 0
rs 8.8571
cc 5
eloc 11
nc 5
nop 0
crap 30
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
    public function className()
56
    {
57
        switch (strtolower($this->name)) {
58
            case self::ROLE_USER:
59
                return 'tag';
60
            case self::ROLE_MANAGER:
61
                return 'success';
62
            case self::ROLE_DEVELOPER:
63
                return 'info';
64
            case self::ROLE_ADMIN:
65
                return 'primary';
66
        }
67
68
        return 'primary';
69
    }
70
}
71