Completed
Push — master ( 289935...a2cbf9 )
by Mahmoud
04:10
created

Controller::SetVisitorEmailController()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace App\Containers\Email\UI\API\Controllers;
4
5
use App\Containers\Email\Actions\SetUserEmailAction;
6
use App\Containers\Email\Actions\SetVisitorEmailAction;
7
use App\Containers\Email\UI\API\Requests\SetUserEmailRequest;
8
use App\Containers\Email\UI\API\Requests\SetVisitorEmailRequest;
9
use App\Port\Controller\Abstracts\PortApiController;
10
11
/**
12
 * Class Controller.
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16
class Controller extends PortApiController
17
{
18
19
    /**
20
     * @param \App\Containers\Email\UI\API\Requests\SetEmailRequest $setEmailRequest
21
     * @param \App\Containers\Email\Actions\SetUserEmailAction   $setUserEmailAction
22
     *
23
     * @return  \Dingo\Api\Http\Response
24
     */
25
    public function setUserEmailController(SetUserEmailRequest $setEmailRequest, SetUserEmailAction $setUserEmailAction)
26
    {
27
        $setUserEmailAction->run($setEmailRequest->id, $setEmailRequest->email);
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Containers\Em...ts\SetUserEmailRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property email does not exist on object<App\Containers\Em...ts\SetUserEmailRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
28
29
        return $this->response->accepted(null, [
30
            'message' => 'User Email Saved Successfully.',
31
        ]);
32
    }
33
34
    /**
35
     * @param \App\Containers\Email\UI\API\Requests\SetEmailRequest $setEmailRequest
36
     * @param \App\Containers\Email\Actions\SetUserEmailAction   $setUserEmailAction
0 ignored issues
show
Documentation introduced by
There is no parameter named $setUserEmailAction. Did you maybe mean $action?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

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

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

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

Loading history...
37
     *
38
     * @return  \Dingo\Api\Http\Response
39
     */
40
    public function SetVisitorEmailController(SetVisitorEmailRequest $setEmailRequest, SetVisitorEmailAction $action)
41
    {
42
        $action->run($setEmailRequest->header('visitor-id'), $setEmailRequest->email);
0 ignored issues
show
Documentation introduced by
The property email does not exist on object<App\Containers\Em...SetVisitorEmailRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
43
44
        return $this->response->accepted(null, [
45
            'message' => 'Visitor Email Saved Successfully.',
46
        ]);
47
    }
48
}
49