Completed
Push — master ( 195b94...7a36f1 )
by Mohamed
04:50
created

Message   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 57
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isDisabled() 0 4 1
A isActiveEvent() 0 4 1
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
use Tinyissue\Model\Role;
16
17
/**
18
 * Tag is model class for tags.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @property int $id
23
 * @property string $name
24
 */
25
class Message extends Model
26
{
27
    /**
28
     * Timestamp disabled.
29
     *
30
     * @var bool
31
     */
32
    public $timestamps = false;
33
34
    /**
35
     * List of allowed columns to be used in $this->fill().
36
     *
37
     * @var array
38
     */
39
    public $fillable = [];
40
41
    /**
42
     * Name of database table.
43
     *
44
     * @var string
45
     */
46
    protected $table = 'messages';
47
48
    /**
49
     * List of default message to role.
50
     *
51
     * @var array
52
     */
53
    public static $defaultMessageToRole = [
54
        Role::ROLE_USER      => 'Minimum',
55
        Role::ROLE_DEVELOPER => 'Standard',
56
        Role::ROLE_MANAGER   => 'Full',
57
        Role::ROLE_ADMIN     => 'Disabled',
58
    ];
59
60
    /**
61
     * Whether the message is disabled or not.
62
     *
63
     * @return bool
64
     */
65
    public function isDisabled()
66
    {
67
        return $this->name === 'Disabled';
68
    }
69
70
    /**
71
     * Whether or not an event is active.
72
     *
73
     * @param string $event
74
     *
75
     * @return bool
76
     */
77
    public function isActiveEvent($event)
78
    {
79
        return (bool) $this->{$event} === true;
80
    }
81
}
82