Test Failed
Pull Request — master (#22)
by Maximo
04:37
created

AccessList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 84
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteAllByRole() 0 3 1
A initialize() 0 9 1
A getSource() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Models;
6
7
class AccessList extends AbstractModel
8
{
9
    /**
10
     *
11
     * @var string
12
     */
13
    public $roles_name;
14
15
    /**
16
     *
17
     * @var string
18
     */
19
    public $resource_name;
20
21
    /**
22
     *
23
     * @var string
24
     */
25
    public $access_name;
26
27
    /**
28
     *
29
     * @var integer
30
     */
31
    public $allowed;
32
33
    /**
34
     *
35
     * @var integer
36
     */
37
    public $apps_id;
38
39
    /**
40
     *
41
     * @var string
42
     */
43
    public $created_at;
44
45
    /**
46
     *
47
     * @var string
48
     */
49
    public $updated_at;
50
51
    /**
52
     *
53
     * @var integer
54
     */
55
    public $is_deleted;
56
57
    /**
58
     * Initialize method for model.
59
     */
60 7
    public function initialize()
61
    {
62 7
        $this->setSource('access_list');
63
64 7
        $this->belongsTo(
65 7
            'roles_name',
66 7
            'Gewaer\Models\Roles',
67 7
            'name',
68 7
            ['alias' => 'role']
69
        );
70 7
    }
71
72
    /**
73
     * Delete all the accest list records for this given role
74
     *
75
     * @param Roles $role
76
     * @return void
77
     */
78 1
    public static function deleteAllByRole(Roles $role): bool
79
    {
80 1
        return (bool) self::find('roles_id = ' . $role->getId())->delete();
1 ignored issue
show
Bug Best Practice introduced by
The expression return (bool)self::find(...ole->getId())->delete() returns the type boolean which is incompatible with the documented return type void.
Loading history...
81
    }
82
83
    /**
84
     * Returns table name mapped in the model.
85
     *
86
     * @return string
87
     */
88 7
    public function getSource(): string
89
    {
90 7
        return 'access_list';
91
    }
92
}
93