Completed
Push — master ( f0acdf...e56775 )
by Mahmoud
07:35 queued 03:57
created

CreateVisitorUserAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A run() 0 10 2
1
<?php
2
3
namespace App\Containers\User\Actions;
4
5
use App\Containers\User\Tasks\CreateUserTask;
6
use App\Containers\User\Tasks\FindUserTask;
7
use App\Port\Action\Abstracts\Action;
8
9
/**
10
 * Class CreateVisitorUserAction.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class CreateVisitorUserAction extends Action
15
{
16
17
    /**
18
     * @var  \App\Containers\User\Actions\CreateUserTask
19
     */
20
    private $createUserTask;
21
22
    /**
23
     * @var  \App\Containers\User\Tasks\FindUserTask
24
     */
25
    private $findUserTask;
26
27
    /**
28
     * CreateUserAction constructor.
29
     *
30
     * @param \App\Containers\User\Tasks\CreateUserTask $createUserTask
31
     * @param \App\Containers\User\Tasks\FindUserTask   $findUserTask
32
     */
33
    public function __construct(CreateUserTask $createUserTask, FindUserTask $findUserTask)
34
    {
35
        $this->createUserTask = $createUserTask;
0 ignored issues
show
Documentation Bug introduced by
It seems like $createUserTask of type object<App\Containers\User\Tasks\CreateUserTask> is incompatible with the declared type object<App\Containers\Us...Actions\CreateUserTask> of property $createUserTask.

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...
36
        $this->findUserTask = $findUserTask;
37
    }
38
39
    /**
40
     * This is to be used only by a Middleware, it is a way to store records about the user
41
     * even before he registers. Very helpful for Mobile apps that doesn't require a user to
42
     * register and login before using the app.
43
     * Then when the user decided to register (to use some extra features) the `UpdateVisitorUserAction`
44
     * Action will be used to update the already created user (user will be determined by his Device ID).
45
     *
46
     * @param            $visitorId
47
     * @param null       $platform
48
     * @param null       $device
49
     * @param bool|false $login
0 ignored issues
show
Bug introduced by
There is no parameter named $login. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
50
     *
51
     * @return  mixed
52
     */
53
    public function run($visitorId, $device = null, $platform = null)
54
    {
55
        $user = $this->findUserTask->byVisitorId($visitorId);
56
57
        if(!$user){
58
            $user = $this->createUserTask->byVisitor($visitorId, $device, $platform);
59
        }
60
61
        return $user;
62
    }
63
}
64