StartPasswordReset   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 31
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 4 1
1
<?php namespace Anomaly\UsersModule\User\Password\Command;
2
3
use Anomaly\UsersModule\User\Contract\UserInterface;
4
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
5
6
7
/**
8
 * Class StartPasswordReset
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class StartPasswordReset
15
{
16
17
    /**
18
     * The user instance.
19
     *
20
     * @var UserInterface
21
     */
22
    protected $user;
23
24
    /**
25
     * Create a new StartPasswordReset instance.
26
     *
27
     * @param UserInterface $user
28
     */
29
    public function __construct(UserInterface $user)
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
        return $users->save($this->user->setAttribute('reset_code', str_random(40)));
43
    }
44
}
45