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

Role::className()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.0187

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 10
cts 11
cp 0.9091
rs 8.8571
cc 5
eloc 11
nc 5
nop 0
crap 5.0187
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