Test Failed
Push — master ( da5def...342071 )
by Christian
04:54
created

PermissionsManager::removePermissions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Omatech\Mage\Core\Domains\Shared\Traits;
4
5
use Omatech\Mage\Core\Domains\Permissions\Contracts\PermissionInterface;
6
use Omatech\Mage\Core\Domains\Permissions\PermissionModel;
7
8
trait PermissionsManager
9
{
10
    private $permissions = [];
11
12
    abstract public function getPermissions();
13
14
    /**
15
     * @param PermissionInterface $permission
16
     *
17
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
18
     *
19
     * @return self
20
     */
21
    public function assignPermission(PermissionInterface $permission): self
22
    {
23
        $this->permissions = app()->make(PermissionModel::class)
24
            ->assignPermission($this->getPermissions(), $permission);
25
26
        return $this;
27
    }
28
29
    /**
30
     * @param array $permissions
31
     *
32
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
33
     *
34
     * @return self
35
     */
36 2
    public function assignPermissions(array $permissions): self
37
    {
38 2
        $this->permissions = app()->make(PermissionModel::class)
39 2
            ->assignPermissions($this->getPermissions(), $permissions);
40
41
        return $this;
42
    }
43
44
    /**
45
     * @param PermissionInterface $permission
46
     *
47
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
48
     *
49
     * @return self
50
     */
51
    public function removePermission(PermissionInterface $permission): self
52
    {
53
        $this->permissions = app()->make(PermissionModel::class)
54
            ->removePermission($this->getPermissions(), $permission);
55
56
        return $this;
57
    }
58
59
    /**
60
     * @param array $permissions
61
     *
62
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
63
     *
64
     * @return self
65
     */
66
    public function removePermissions(array $permissions): self
67
    {
68
        $this->permissions = app()->make(PermissionModel::class)
69
            ->removePermissions($this->getPermissions(), $permissions);
70
71
        return $this;
72
    }
73
}
74