Completed
Push — master ( f8bbe7...f92ec2 )
by Christian
06:55
created

RolesManager::removeRole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Omatech\Mage\Core\Domains\Shared\Traits;
4
5
use Omatech\Mage\Core\Domains\Roles\Contracts\RoleInterface;
6
use Omatech\Mage\Core\Domains\Roles\RoleModel;
7
8
trait RolesManager
9
{
10
    /**
11
     * @param RoleInterface $role
12
     *
13
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
14
     *
15
     * @return self
16
     */
17 1
    public function assignRole(RoleInterface $role): self
18
    {
19 1
        $this->roles = app()->make(RoleModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20 1
            ->assignRole($this->getRoles(), $role);
0 ignored issues
show
Bug introduced by
It seems like getRoles() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
            ->assignRole($this->/** @scrutinizer ignore-call */ getRoles(), $role);
Loading history...
21
22 1
        return $this;
23
    }
24
25
    /**
26
     * @param array $roles
27
     *
28
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
29
     *
30
     * @return self
31
     */
32 7
    public function assignRoles(array $roles): self
33
    {
34 7
        $this->roles = app()->make(RoleModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35 7
            ->assignRoles($this->getRoles(), $roles);
36
37 6
        return $this;
38
    }
39
40
    /**
41
     * @param RoleInterface $role
42
     *
43
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
44
     *
45
     * @return self
46
     */
47 1
    public function removeRole(RoleInterface $role): self
48
    {
49 1
        $this->roles = app()->make(RoleModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
50 1
            ->removeRole($this->getRoles(), $role);
51
52 1
        return $this;
53
    }
54
55
    /**
56
     * @param array $roles
57
     *
58
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
59
     *
60
     * @return self
61
     */
62 2
    public function removeRoles(array $roles): self
63
    {
64 2
        $this->roles = app()->make(RoleModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
65 2
            ->removeRoles($this->getRoles(), $roles);
66
67 1
        return $this;
68
    }
69
}
70