Passed
Push — master ( 342071...ce1cac )
by Christian
04:33
created

PermissionsManager::removePermissions()   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\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 3
    public function assignPermission(PermissionInterface $permission): self
22
    {
23 3
        $this->permissions = app()->make(PermissionModel::class)
24 3
            ->assignPermission($this->getPermissions(), $permission);
25
26 3
        return $this;
27
    }
28
29
    /**
30
     * @param array $permissions
31
     *
32
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
33
     *
34
     * @return self
35
     */
36 16
    public function assignPermissions(array $permissions): self
37
    {
38 16
        $this->permissions = app()->make(PermissionModel::class)
39 16
            ->assignPermissions($this->getPermissions(), $permissions);
40
41 14
        return $this;
42
    }
43
44
    /**
45
     * @param PermissionInterface $permission
46
     *
47
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
48
     *
49
     * @return self
50
     */
51 2
    public function removePermission(PermissionInterface $permission): self
52
    {
53 2
        $this->permissions = app()->make(PermissionModel::class)
54 2
            ->removePermission($this->getPermissions(), $permission);
55
56 2
        return $this;
57
    }
58
59
    /**
60
     * @param array $permissions
61
     *
62
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
63
     *
64
     * @return self
65
     */
66 4
    public function removePermissions(array $permissions): self
67
    {
68 4
        $this->permissions = app()->make(PermissionModel::class)
69 4
            ->removePermissions($this->getPermissions(), $permissions);
70
71 2
        return $this;
72
    }
73
}
74