StartUserActivation::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php namespace Anomaly\UsersModule\User\Command;
2
3
use Anomaly\UsersModule\User\Contract\UserInterface;
4
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
5
6
7
/**
8
 * Class StartUserActivation
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class StartUserActivation
15
{
16
17
    /**
18
     * The user instance.
19
     *
20
     * @var UserInterface
21
     */
22
    protected $user;
23
24
    /**
25
     * Create a new StartUserActivation instance.
26
     *
27
     * @param UserInterface $user
28
     */
29
    function __construct(UserInterface $user)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
    {
31
        $this->user = $user;
32
    }
33
34
    /**
35
     * Handle the command.
36
     *
37
     * @param  UserRepositoryInterface $users
38
     * @return bool
39
     */
40
    public function handle(UserRepositoryInterface $users)
41
    {
42
        $users->save($this->user->setAttribute('activation_code', str_random(40)));
43
44
        return true;
45
    }
46
}
47