Completed
Push — master ( fd4dfb...07d033 )
by Mahmoud
03:04
created

CreateRoleTask::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 3
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\Port\Task\Abstracts\Task;
8
9
/**
10
 * Class CreateRoleTask.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class CreateRoleTask extends Task
15
{
16
17
    /**
18
     * @var  \App\Containers\Authorization\Data\Repositories\RoleRepository
19
     */
20
    private $roleRepository;
21
22
    /**
23
     * @var  \App\Containers\User\Tasks\FindUserByIdTask
24
     */
25
    private $findUserByIdTask;
0 ignored issues
show
Unused Code introduced by
The property $findUserByIdTask is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
26
27
    /**
28
     * CreateRoleTask constructor.
29
     *
30
     * @param \App\Containers\Authorization\Data\Repositories\RoleRepository $roleRepository
31
     */
32
    public function __construct(RoleRepository $roleRepository)
33
    {
34
        $this->roleRepository = $roleRepository;
35
    }
36
37
    /**
38
     * @param $name
39
     * @param $description
40
     * @param $displayName
41
     *
42
     * @return  mixed
43
     */
44
    public function run($name, $description = null, $displayName = null)
45
    {
46
47
        return $this->roleRepository->create([
48
            'name'          => $name,
49
            'description'   => $description,
50
            'display_name' => $displayName,
51
        ]);
52
    }
53
54
}
55