LoginJob   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 7 2
1
<?php namespace Cerbero\Auth\Jobs;
2
3
use Cerbero\Auth\Exceptions\DisplayException;
4
use Illuminate\Contracts\Auth\Guard;
5
use Illuminate\Contracts\Bus\SelfHandling;
6
7
class LoginJob implements SelfHandling {
8
9
	/**
10
	 * @author	Andrea Marco Sartori
11
	 * @var		array	$credentials	Credentials.
12
	 */
13
	public $credentials;
14
15
	/**
16
	 * @author	Andrea Marco Sartori
17
	 * @var		boolean	$remember	Whether to remember the session.
18
	 */
19
	public $remember;
20
21
	/**
22
	 * Create a new job instance.
23
	 *
24
	 * @return void
25
	 */
26
	public function __construct()
27
	{
28
		$this->credentials = app('request')->only(config('_auth.login.fields'));
29
30
		$this->remember = app('request')->get(config('_auth.login.remember_me'), false);
31
	}
32
33
	/**
34
	 * Execute the job.
35
	 *
36
	 * @return void
37
	 */
38
	public function handle(Guard $auth)
39
	{
40
		if( ! $auth->attempt($this->credentials, $this->remember))
41
		{
42
			throw new DisplayException('auth::login.error');
43
		}
44
	}
45
46
}
47