ResetJob::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4286
c 2
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php namespace Cerbero\Auth\Jobs;
2
3
use Cerbero\Auth\Exceptions\DisplayException;
4
use Cerbero\Auth\Repositories\UserRepositoryInterface;
5
use Illuminate\Contracts\Bus\SelfHandling;
6
use Illuminate\Contracts\Hashing\Hasher;
7
8
class ResetJob implements SelfHandling {
9
10
	/**
11
	 * @author	Andrea Marco Sartori
12
	 * @var		string	$password	Password input.
13
	 */
14
	public $password;
15
16
	/**
17
	 * @author	Andrea Marco Sartori
18
	 * @var		string	$token	Reset token.
19
	 */
20
	public $token;
21
22
	/**
23
	 * Create a new job instance.
24
	 *
25
	 * @return void
26
	 */
27
	public function __construct($password, $token)
28
	{
29
		$this->password = $password;
30
31
		$this->token = $token;
32
	}
33
34
	/**
35
	 * Execute the job.
36
	 *
37
	 * @return void
38
	 */
39
	public function handle(UserRepositoryInterface $users, Hasher $hasher)
40
	{
41
		if( ! $user = $users->findByResetToken($this->token))
42
		{
43
			throw new DisplayException('auth::reset.error');
44
		}
45
46
		$users->resetPassword($user, $hasher->make($this->password));
47
	}
48
49
}
50