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

DetachPermissionsFromRoleTask::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
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