Completed
Push — master ( 0b2677...ff7e0f )
by Mahmoud
03:45
created

DetachPermissionsFromRoleTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 8 1
1
<?php
2
3
namespace App\Containers\Authorization\Tasks;
4
5
use App\Containers\Authorization\Actions\GetRoleAction;
6
use App\Port\Task\Abstracts\Task;
7
8
/**
9
 * Class DetachPermissionsFromRoleTask.
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13
class DetachPermissionsFromRoleTask extends Task
14
{
15
16
    /**
17
     * @var  \App\Containers\Authorization\Actions\GetRoleAction
18
     */
19
    private $getRoleAction;
20
21
22
    /**
23
     * AttachPermissionsToRoleTask constructor.
24
     *
25
     * @param \App\Containers\Authorization\Actions\GetRoleAction $getRoleAction
26
     */
27
    public function __construct(GetRoleAction $getRoleAction)
28
    {
29
        $this->getRoleAction = $getRoleAction;
30
    }
31
32
    /**
33
     * @param string       $roleName
34
     * @param array|string $permissionNames
35
     *
36
     * @return  mixed
37
     */
38
    public function run($roleName, $permissionNames)
39
    {
40
        $role = $this->getRoleAction->run($roleName);
41
42
        $role->revokePermissionTo($permissionNames);
43
44
        return $role;
45
    }
46
}
47