DeleteRoleTask::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace App\Containers\Authorization\Tasks;
4
5
use App\Containers\Authorization\Data\Repositories\RoleRepository;
6
use App\Containers\Authorization\Models\Role;
7
use App\Ship\Parents\Actions\Action;
8
9
/**
10
 * Class DeleteRoleTask.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class DeleteRoleTask extends Action
15
{
16
17
    /**
18
     * @var  \App\Containers\Authorization\Data\Repositories\RoleRepository
19
     */
20
    private $roleRepository;
21
22
    /**
23
     * DeleteRoleTask constructor.
24
     *
25
     * @param \App\Containers\Authorization\Data\Repositories\RoleRepository $roleRepository
26
     */
27
    public function __construct(RoleRepository $roleRepository)
28
    {
29
        $this->roleRepository = $roleRepository;
30
    }
31
32
    /**
33
     * @param Integer|Role $role
34
     *
35
     * @return  bool
36
     */
37
    public function run($role)
38
    {
39
        if ($role instanceof Role) {
40
            $role = $role->id;
41
        }
42
43
        // delete the record from the roles table.
44
        return $this->roleRepository->delete($role);
45
    }
46
}
47