Completed
Push — master ( 4c5f95...615c30 )
by Mahmoud
04:04
created

Controller::confirmUserEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace App\Containers\Email\UI\WEB\Controllers;
4
5
use App\Containers\Email\UI\API\Requests\ConfirmUserEmailRequest;
6
use App\Containers\Email\Actions\ValidateConfirmationCodeAction;
7
use App\Containers\User\Actions\FindUserByIdAction;
8
use App\Port\Controller\Abstracts\PortWebController;
9
use Illuminate\Support\Facades\Config;
10
11
/**
12
 * Class Controller.
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16
class Controller extends PortWebController
17
{
18
19
    /**
20
     * @param \App\Containers\Email\UI\API\Requests\ConfirmUserEmailRequest       $confirmUserEmailRequest
21
     * @param \App\Containers\User\Actions\FindUserByIdAction              $findUserByIdAction
22
     * @param \App\Containers\Email\Actions\ValidateConfirmationCodeAction $validateConfirmationCodeAction
23
     *
24
     * @return  \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
25
     */
26
    public function confirmUserEmail(
27
        ConfirmUserEmailRequest $confirmUserEmailRequest,
28
        FindUserByIdAction $findUserByIdAction,
29
        ValidateConfirmationCodeAction $validateConfirmationCodeAction
30
    ) {
31
32
        // find user by ID
33
        $user = $findUserByIdAction->run($confirmUserEmailRequest->id);
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Containers\Em...onfirmUserEmailRequest>. 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...
34
35
        // validate the confirmation code and update user status is code is valid
36
        $validateConfirmationCodeAction->run($user, $confirmUserEmailRequest->code);
0 ignored issues
show
Documentation introduced by
The property code does not exist on object<App\Containers\Em...onfirmUserEmailRequest>. 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...
37
38
        // redirect to the app URL
39
        return redirect(Config::get('app.url'));
40
    }
41
42
}
43