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

PermissionsManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 13
c 1
b 1
f 0
dl 0
loc 60
ccs 16
cts 16
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A assignPermission() 0 6 1
A assignPermissions() 0 6 1
A removePermission() 0 6 1
A removePermissions() 0 6 1
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
    /**
11
     * @param PermissionInterface $permission
12
     *
13
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
14
     *
15
     * @return self
16
     */
17 3
    public function assignPermission(PermissionInterface $permission): self
18
    {
19 3
        $this->permissions = app()->make(PermissionModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property permissions does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20 3
            ->assignPermission($this->getPermissions(), $permission);
0 ignored issues
show
Bug introduced by
It seems like getPermissions() 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
            ->assignPermission($this->/** @scrutinizer ignore-call */ getPermissions(), $permission);
Loading history...
21
22 3
        return $this;
23
    }
24
25
    /**
26
     * @param array $permissions
27
     *
28
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
29
     *
30
     * @return self
31
     */
32 14
    public function assignPermissions(array $permissions): self
33
    {
34 14
        $this->permissions = app()->make(PermissionModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property permissions does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35 14
            ->assignPermissions($this->getPermissions(), $permissions);
36
37 12
        return $this;
38
    }
39
40
    /**
41
     * @param PermissionInterface $permission
42
     *
43
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
44
     *
45
     * @return self
46
     */
47 2
    public function removePermission(PermissionInterface $permission): self
48
    {
49 2
        $this->permissions = app()->make(PermissionModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property permissions does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
50 2
            ->removePermission($this->getPermissions(), $permission);
51
52 2
        return $this;
53
    }
54
55
    /**
56
     * @param array $permissions
57
     *
58
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
59
     *
60
     * @return self
61
     */
62 4
    public function removePermissions(array $permissions): self
63
    {
64 4
        $this->permissions = app()->make(PermissionModel::class)
0 ignored issues
show
Bug Best Practice introduced by
The property permissions does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
65 4
            ->removePermissions($this->getPermissions(), $permissions);
66
67 2
        return $this;
68
    }
69
}
70