ResetJob   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 42
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 9 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