Completed
Push — master ( 563d71...071fd8 )
by Mahmoud
03:32
created

CreateAdminAction::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace App\Containers\User\Actions;
4
5
use App\Containers\Authorization\Tasks\AssignRoleTask;
6
use App\Containers\User\Tasks\CreateUserByCredentialsTask;
7
use App\Containers\User\Tasks\FireUserCreatedEventTask;
8
use App\Port\Action\Abstracts\Action;
9
10
/**
11
 * Class CreateAdminAction.
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class CreateAdminAction extends Action
16
{
17
18
    /**
19
     * @var  \App\Containers\User\Actions\CreateUserByCredentialsTask
20
     */
21
    private $createUserByCredentialsTask;
22
23
    /**
24
     * @var  \App\Containers\User\Actions\FireUserCreatedEventTask
25
     */
26
    private $fireUserCreatedEventTask;
27
28
    /**
29
     * @var  \App\Containers\Authorization\Tasks\AssignRoleTask
30
     */
31
    private $assignRoleTask;
32
33
    /**
34
     * CreateUserAction constructor.
35
     *
36
     * @param \App\Containers\User\Tasks\CreateUserByCredentialsTask $createUserByCredentialsTask
37
     * @param \App\Containers\User\Tasks\FireUserCreatedEventTask    $fireUserCreatedEventTask
38
     * @param \App\Containers\Authorization\Tasks\AssignRoleTask     $assignRoleTask
39
     */
40
    public function __construct(
41
        CreateUserByCredentialsTask $createUserByCredentialsTask,
42
        FireUserCreatedEventTask $fireUserCreatedEventTask,
43
        AssignRoleTask $assignRoleTask
44
    ) {
45
        $this->createUserByCredentialsTask = $createUserByCredentialsTask;
0 ignored issues
show
Documentation Bug introduced by
It seems like $createUserByCredentialsTask of type object<App\Containers\Us...eUserByCredentialsTask> is incompatible with the declared type object<App\Containers\Us...eUserByCredentialsTask> of property $createUserByCredentialsTask.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
        $this->fireUserCreatedEventTask = $fireUserCreatedEventTask;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fireUserCreatedEventTask of type object<App\Containers\Us...reUserCreatedEventTask> is incompatible with the declared type object<App\Containers\Us...reUserCreatedEventTask> of property $fireUserCreatedEventTask.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
        $this->assignRoleTask = $assignRoleTask;
48
    }
49
50
    /**
51
     * @param $email
52
     * @param $password
53
     * @param $name
54
     *
55
     * @return  mixed
56
     */
57
    public function run($email, $password, $name)
58
    {
59
        $admin = $this->createUserByCredentialsTask->run($email, $password, $name);
60
61
        $this->assignRoleTask->run($admin, ['admin']);
62
63
        return $admin;
64
    }
65
}
66