Completed
Push — master ( 9822a8...9d715b )
by Mahmoud
05:21
created

ConfirmUserEmailTask::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace App\Containers\Email\Tasks;
4
5
use App\Containers\User\Models\User;
6
use App\Port\Action\Abstracts\Action;
7
8
/**
9
 * Class ConfirmUserEmailTask.
10
 *
11
 * @author Mahmoud Zalt <[email protected]>
12
 */
13
class ConfirmUserEmailTask extends Action
14
{
15
16
    /**
17
     * @param \App\Containers\User\Models\User $user
18
     *
19
     * @return  \App\Containers\User\Models\User
20
     */
21
    public function run(User $user)
22
    {
23
        // update user state
24
        $user->confirmed = true;
0 ignored issues
show
Documentation introduced by
The property confirmed does not exist on object<App\Containers\User\Models\User>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
25
        $user->save();
26
27
        return $user;
28
    }
29
}
30