DeleteRoleTask   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 9 2
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