Completed
Push — master ( fcae4c...6f6645 )
by Andrea Marco
02:23
created
src/Http/Controllers/AuthController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 	 * Set the dependencies.
55 55
 	 *
56 56
 	 * @author	Andrea Marco Sartori
57
-	 * @param	Illuminate\Contracts\Bus\Dispatcher	$bus
57
+	 * @param	Dispatcher	$bus
58 58
 	 * @return	void
59 59
 	 */
60 60
 	public function __construct(Dispatcher $bus)
Please login to merge, or discard this patch.
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -14,187 +14,187 @@
 block discarded – undo
14 14
 
15 15
 class AuthController extends Controller {
16 16
 
17
-	/**
18
-	 * @author	Andrea Marco Sartori
19
-	 * @var		Illuminate\Contracts\Bus\Dispatcher	$bus	Bus dispatcher.
20
-	 */
21
-	protected $bus;
22
-
23
-	/**
24
-	 * @author	Andrea Marco Sartori
25
-	 * @var		array	$loginPipes	List of pipes for the login process.
26
-	 */
27
-	protected $loginPipes = ['DispatchEvent', 'Throttle'];
28
-
29
-	/**
30
-	 * @author	Andrea Marco Sartori
31
-	 * @var		array	$logoutPipes	List of pipes for the logout process.
32
-	 */
33
-	protected $logoutPipes = ['DispatchEvent'];
34
-
35
-	/**
36
-	 * @author	Andrea Marco Sartori
37
-	 * @var		array	$registerPipes	List of pipes for the register process.
38
-	 */
39
-	protected $registerPipes = ['DispatchEvent', 'Login', 'Notify', 'Hash'];
40
-
41
-	/**
42
-	 * @author	Andrea Marco Sartori
43
-	 * @var		array	$recoverPipes	List of pipes for the password recover process.
44
-	 */
45
-	protected $recoverPipes = ['DispatchEvent', 'Notify', 'Store'];
46
-
47
-	/**
48
-	 * @author	Andrea Marco Sartori
49
-	 * @var		array	$resetPipes	List of pipes for the password reset process.
50
-	 */
51
-	protected $resetPipes = ['DispatchEvent'];
17
+    /**
18
+     * @author	Andrea Marco Sartori
19
+     * @var		Illuminate\Contracts\Bus\Dispatcher	$bus	Bus dispatcher.
20
+     */
21
+    protected $bus;
22
+
23
+    /**
24
+     * @author	Andrea Marco Sartori
25
+     * @var		array	$loginPipes	List of pipes for the login process.
26
+     */
27
+    protected $loginPipes = ['DispatchEvent', 'Throttle'];
28
+
29
+    /**
30
+     * @author	Andrea Marco Sartori
31
+     * @var		array	$logoutPipes	List of pipes for the logout process.
32
+     */
33
+    protected $logoutPipes = ['DispatchEvent'];
34
+
35
+    /**
36
+     * @author	Andrea Marco Sartori
37
+     * @var		array	$registerPipes	List of pipes for the register process.
38
+     */
39
+    protected $registerPipes = ['DispatchEvent', 'Login', 'Notify', 'Hash'];
40
+
41
+    /**
42
+     * @author	Andrea Marco Sartori
43
+     * @var		array	$recoverPipes	List of pipes for the password recover process.
44
+     */
45
+    protected $recoverPipes = ['DispatchEvent', 'Notify', 'Store'];
46
+
47
+    /**
48
+     * @author	Andrea Marco Sartori
49
+     * @var		array	$resetPipes	List of pipes for the password reset process.
50
+     */
51
+    protected $resetPipes = ['DispatchEvent'];
52 52
 	
53
-	/**
54
-	 * Set the dependencies.
55
-	 *
56
-	 * @author	Andrea Marco Sartori
57
-	 * @param	Illuminate\Contracts\Bus\Dispatcher	$bus
58
-	 * @return	void
59
-	 */
60
-	public function __construct(Dispatcher $bus)
61
-	{
62
-		$this->bus = $bus;
63
-	}
64
-
65
-	/**
66
-	 * Display the login page.
67
-	 *
68
-	 * @author	Andrea Marco Sartori
69
-	 * @return	Illuminate\Http\Response
70
-	 */
71
-	public function showLogin()
72
-	{
73
-		$login = config('_auth.login.view');
74
-
75
-		return view($login);
76
-	}
77
-
78
-	/**
79
-	 * Log the user in.
80
-	 *
81
-	 * @author	Andrea Marco Sartori
82
-	 * @return	Illuminate\Http\RedirectResponse
83
-	 */
84
-	public function login(LoginRequest $request)
85
-	{
86
-		$this->bus->pipeThrough($this->pipesOf('login'))->dispatchFrom(LoginJob::class, $request);
87
-
88
-		return redirect()->route(config('_auth.login.redirect'));
89
-	}
90
-
91
-	/**
92
-	 * Retrieve the pipes of a given process.
93
-	 *
94
-	 * @author	Andrea Marco Sartori
95
-	 * @param	string	$process
96
-	 * @return	array
97
-	 */
98
-	protected function pipesOf($process)
99
-	{
100
-		$Process = ucfirst($process);
101
-
102
-		return array_map(function($pipe) use($Process)
103
-		{
104
-			return "Cerbero\Auth\Pipes\\{$Process}\\{$pipe}";
105
-
106
-		}, $this->{"{$process}Pipes"});
107
-	}
108
-
109
-	/**
110
-	 * Log the user out.
111
-	 *
112
-	 * @author	Andrea Marco Sartori
113
-	 * @return	Illuminate\Http\RedirectResponse
114
-	 */
115
-	public function logout()
116
-	{
117
-		$this->bus->pipeThrough($this->pipesOf('logout'))->dispatchNow(new LogoutJob);
118
-
119
-		return redirect()->route(config('_auth.logout.redirect'));
120
-	}
121
-
122
-	/**
123
-	 * Display the registration page.
124
-	 *
125
-	 * @author	Andrea Marco Sartori
126
-	 * @return	Illuminate\Http\Response
127
-	 */
128
-	public function showRegister()
129
-	{
130
-		$register = config('_auth.register.view');
131
-
132
-		return view($register);
133
-	}
134
-
135
-	/**
136
-	 * Register the user.
137
-	 *
138
-	 * @author	Andrea Marco Sartori
139
-	 * @return	Illuminate\Http\RedirectResponse
140
-	 */
141
-	public function register(RegisterRequest $request)
142
-	{
143
-		$this->bus->pipeThrough($this->pipesOf('register'))->dispatchFrom(RegisterJob::class, $request);
144
-
145
-		return redirect()->route(config('_auth.register.redirect'))->withSuccess(trans('auth::register.success'));
146
-	}
147
-
148
-	/**
149
-	 * Display the recover page.
150
-	 *
151
-	 * @author	Andrea Marco Sartori
152
-	 * @return	Illuminate\Http\Response
153
-	 */
154
-	public function showRecover()
155
-	{
156
-		$recover = config('_auth.recover.view');
157
-
158
-		return view($recover);
159
-	}
160
-
161
-	/**
162
-	 * Remember the user password.
163
-	 *
164
-	 * @author	Andrea Marco Sartori
165
-	 * @return	Illuminate\Http\RedirectResponse
166
-	 */
167
-	public function recover(RecoverRequest $request)
168
-	{
169
-		$this->bus->pipeThrough($this->pipesOf('recover'))->dispatchFrom(RecoverJob::class, $request);
170
-
171
-		return back()->withSuccess(trans('auth::recover.success'));
172
-	}
173
-
174
-	/**
175
-	 * Display the reset page.
176
-	 *
177
-	 * @author	Andrea Marco Sartori
178
-	 * @return	Illuminate\Http\Response
179
-	 */
180
-	public function showReset($token)
181
-	{
182
-		$reset = config('_auth.reset.view');
183
-
184
-		return view($reset);
185
-	}
186
-
187
-	/**
188
-	 * Reset the user password.
189
-	 *
190
-	 * @author	Andrea Marco Sartori
191
-	 * @return	Illuminate\Http\RedirectResponse
192
-	 */
193
-	public function reset(ResetRequest $request, $token)
194
-	{
195
-		$this->bus->pipeThrough($this->pipesOf('reset'))->dispatchFrom(ResetJob::class, $request, compact('token'));
196
-
197
-		return redirect()->route('login.index')->withSuccess(trans('auth::reset.success'));
198
-	}
53
+    /**
54
+     * Set the dependencies.
55
+     *
56
+     * @author	Andrea Marco Sartori
57
+     * @param	Illuminate\Contracts\Bus\Dispatcher	$bus
58
+     * @return	void
59
+     */
60
+    public function __construct(Dispatcher $bus)
61
+    {
62
+        $this->bus = $bus;
63
+    }
64
+
65
+    /**
66
+     * Display the login page.
67
+     *
68
+     * @author	Andrea Marco Sartori
69
+     * @return	Illuminate\Http\Response
70
+     */
71
+    public function showLogin()
72
+    {
73
+        $login = config('_auth.login.view');
74
+
75
+        return view($login);
76
+    }
77
+
78
+    /**
79
+     * Log the user in.
80
+     *
81
+     * @author	Andrea Marco Sartori
82
+     * @return	Illuminate\Http\RedirectResponse
83
+     */
84
+    public function login(LoginRequest $request)
85
+    {
86
+        $this->bus->pipeThrough($this->pipesOf('login'))->dispatchFrom(LoginJob::class, $request);
87
+
88
+        return redirect()->route(config('_auth.login.redirect'));
89
+    }
90
+
91
+    /**
92
+     * Retrieve the pipes of a given process.
93
+     *
94
+     * @author	Andrea Marco Sartori
95
+     * @param	string	$process
96
+     * @return	array
97
+     */
98
+    protected function pipesOf($process)
99
+    {
100
+        $Process = ucfirst($process);
101
+
102
+        return array_map(function($pipe) use($Process)
103
+        {
104
+            return "Cerbero\Auth\Pipes\\{$Process}\\{$pipe}";
105
+
106
+        }, $this->{"{$process}Pipes"});
107
+    }
108
+
109
+    /**
110
+     * Log the user out.
111
+     *
112
+     * @author	Andrea Marco Sartori
113
+     * @return	Illuminate\Http\RedirectResponse
114
+     */
115
+    public function logout()
116
+    {
117
+        $this->bus->pipeThrough($this->pipesOf('logout'))->dispatchNow(new LogoutJob);
118
+
119
+        return redirect()->route(config('_auth.logout.redirect'));
120
+    }
121
+
122
+    /**
123
+     * Display the registration page.
124
+     *
125
+     * @author	Andrea Marco Sartori
126
+     * @return	Illuminate\Http\Response
127
+     */
128
+    public function showRegister()
129
+    {
130
+        $register = config('_auth.register.view');
131
+
132
+        return view($register);
133
+    }
134
+
135
+    /**
136
+     * Register the user.
137
+     *
138
+     * @author	Andrea Marco Sartori
139
+     * @return	Illuminate\Http\RedirectResponse
140
+     */
141
+    public function register(RegisterRequest $request)
142
+    {
143
+        $this->bus->pipeThrough($this->pipesOf('register'))->dispatchFrom(RegisterJob::class, $request);
144
+
145
+        return redirect()->route(config('_auth.register.redirect'))->withSuccess(trans('auth::register.success'));
146
+    }
147
+
148
+    /**
149
+     * Display the recover page.
150
+     *
151
+     * @author	Andrea Marco Sartori
152
+     * @return	Illuminate\Http\Response
153
+     */
154
+    public function showRecover()
155
+    {
156
+        $recover = config('_auth.recover.view');
157
+
158
+        return view($recover);
159
+    }
160
+
161
+    /**
162
+     * Remember the user password.
163
+     *
164
+     * @author	Andrea Marco Sartori
165
+     * @return	Illuminate\Http\RedirectResponse
166
+     */
167
+    public function recover(RecoverRequest $request)
168
+    {
169
+        $this->bus->pipeThrough($this->pipesOf('recover'))->dispatchFrom(RecoverJob::class, $request);
170
+
171
+        return back()->withSuccess(trans('auth::recover.success'));
172
+    }
173
+
174
+    /**
175
+     * Display the reset page.
176
+     *
177
+     * @author	Andrea Marco Sartori
178
+     * @return	Illuminate\Http\Response
179
+     */
180
+    public function showReset($token)
181
+    {
182
+        $reset = config('_auth.reset.view');
183
+
184
+        return view($reset);
185
+    }
186
+
187
+    /**
188
+     * Reset the user password.
189
+     *
190
+     * @author	Andrea Marco Sartori
191
+     * @return	Illuminate\Http\RedirectResponse
192
+     */
193
+    public function reset(ResetRequest $request, $token)
194
+    {
195
+        $this->bus->pipeThrough($this->pipesOf('reset'))->dispatchFrom(ResetJob::class, $request, compact('token'));
196
+
197
+        return redirect()->route('login.index')->withSuccess(trans('auth::reset.success'));
198
+    }
199 199
 
200 200
 }
Please login to merge, or discard this patch.
src/Jobs/RecoverJob.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	/**
24 24
 	 * Execute the job.
25 25
 	 *
26
-	 * @return void
26
+	 * @return string
27 27
 	 */
28 28
 	public function handle()
29 29
 	{
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@
 block discarded – undo
4 4
 
5 5
 class RecoverJob implements SelfHandling {
6 6
 
7
-	/**
8
-	 * @author	Andrea Marco Sartori
9
-	 * @var		string	$email	Email input.
10
-	 */
11
-	public $email;
7
+    /**
8
+     * @author	Andrea Marco Sartori
9
+     * @var		string	$email	Email input.
10
+     */
11
+    public $email;
12 12
 
13
-	/**
14
-	 * Create a new job instance.
15
-	 *
16
-	 * @return void
17
-	 */
18
-	public function __construct($email)
19
-	{
20
-		$this->email = $email;
21
-	}
13
+    /**
14
+     * Create a new job instance.
15
+     *
16
+     * @return void
17
+     */
18
+    public function __construct($email)
19
+    {
20
+        $this->email = $email;
21
+    }
22 22
 
23
-	/**
24
-	 * Execute the job.
25
-	 *
26
-	 * @return void
27
-	 */
28
-	public function handle()
29
-	{
30
-		return str_random(10);
31
-	}
23
+    /**
24
+     * Execute the job.
25
+     *
26
+     * @return void
27
+     */
28
+    public function handle()
29
+    {
30
+        return str_random(10);
31
+    }
32 32
 
33 33
 }
Please login to merge, or discard this patch.
src/Pipes/AbstractEventDispatcherPipe.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@
 block discarded – undo
20 20
 	 * Set the dependencies.
21 21
 	 *
22 22
 	 * @author	Andrea Marco Sartori
23
-	 * @param	Illuminate\Contracts\Container\Container	$container
24
-	 * @param	Illuminate\Contracts\Events\Dispatcher	$dispatcher
23
+	 * @param	Container	$container
24
+	 * @param	Dispatcher	$dispatcher
25 25
 	 * @return	void
26 26
 	 */
27 27
 	public function __construct(Container $container, Dispatcher $dispatcher)
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -10,78 +10,78 @@
 block discarded – undo
10 10
  */
11 11
 abstract class AbstractEventDispatcherPipe extends AbstractPipe {
12 12
 
13
-	/**
14
-	 * @author	Andrea Marco Sartori
15
-	 * @var		Illuminate\Contracts\Events\Dispatcher	$dispatcher	Event dispatcher.
16
-	 */
17
-	protected $dispatcher;
13
+    /**
14
+     * @author	Andrea Marco Sartori
15
+     * @var		Illuminate\Contracts\Events\Dispatcher	$dispatcher	Event dispatcher.
16
+     */
17
+    protected $dispatcher;
18 18
 	
19
-	/**
20
-	 * Set the dependencies.
21
-	 *
22
-	 * @author	Andrea Marco Sartori
23
-	 * @param	Illuminate\Contracts\Container\Container	$container
24
-	 * @param	Illuminate\Contracts\Events\Dispatcher	$dispatcher
25
-	 * @return	void
26
-	 */
27
-	public function __construct(Container $container, Dispatcher $dispatcher)
28
-	{
29
-		parent::__construct($container);
19
+    /**
20
+     * Set the dependencies.
21
+     *
22
+     * @author	Andrea Marco Sartori
23
+     * @param	Illuminate\Contracts\Container\Container	$container
24
+     * @param	Illuminate\Contracts\Events\Dispatcher	$dispatcher
25
+     * @return	void
26
+     */
27
+    public function __construct(Container $container, Dispatcher $dispatcher)
28
+    {
29
+        parent::__construct($container);
30 30
 
31
-		$this->dispatcher = $dispatcher;
32
-	}
31
+        $this->dispatcher = $dispatcher;
32
+    }
33 33
 
34
-	/**
35
-	 * Run before the job is handled.
36
-	 *
37
-	 * @param	mixed	$job
38
-	 * @return	mixed
39
-	 */
40
-	public function before($job)
41
-	{
42
-		$this->fireEventOn('start', $job);
43
-	}
34
+    /**
35
+     * Run before the job is handled.
36
+     *
37
+     * @param	mixed	$job
38
+     * @return	mixed
39
+     */
40
+    public function before($job)
41
+    {
42
+        $this->fireEventOn('start', $job);
43
+    }
44 44
 
45
-	/**
46
-	 * Fire an event at some point.
47
-	 *
48
-	 * @author	Andrea Marco Sartori
49
-	 * @param	string	$action
50
-	 * @param	mixed	$payload
51
-	 * @return	void
52
-	 */
53
-	private function fireEventOn($action, $payload)
54
-	{
55
-		$event = $this->getEventName();
45
+    /**
46
+     * Fire an event at some point.
47
+     *
48
+     * @author	Andrea Marco Sartori
49
+     * @param	string	$action
50
+     * @param	mixed	$payload
51
+     * @return	void
52
+     */
53
+    private function fireEventOn($action, $payload)
54
+    {
55
+        $event = $this->getEventName();
56 56
 
57
-		$this->dispatcher->fire("auth.{$event}.{$action}", $payload);
58
-	}
57
+        $this->dispatcher->fire("auth.{$event}.{$action}", $payload);
58
+    }
59 59
 
60
-	/**
61
-	 * Retrieve the event name.
62
-	 *
63
-	 * @author	Andrea Marco Sartori
64
-	 * @return	string
65
-	 */
66
-	protected function getEventName()
67
-	{
68
-		$chunks = explode('\\', get_class($this));
60
+    /**
61
+     * Retrieve the event name.
62
+     *
63
+     * @author	Andrea Marco Sartori
64
+     * @return	string
65
+     */
66
+    protected function getEventName()
67
+    {
68
+        $chunks = explode('\\', get_class($this));
69 69
 
70
-		$name = $chunks[count($chunks) - 2];
70
+        $name = $chunks[count($chunks) - 2];
71 71
 
72
-		return strtolower($name);
73
-	}
72
+        return strtolower($name);
73
+    }
74 74
 
75
-	/**
76
-	 * Run after the handled job.
77
-	 *
78
-	 * @param	mixed	$handled
79
-	 * @param	mixed	$job
80
-	 * @return	mixed
81
-	 */
82
-	public function after($handled, $job)
83
-	{
84
-		$this->fireEventOn('end', [$handled, $job]);
85
-	}
75
+    /**
76
+     * Run after the handled job.
77
+     *
78
+     * @param	mixed	$handled
79
+     * @param	mixed	$job
80
+     * @return	mixed
81
+     */
82
+    public function after($handled, $job)
83
+    {
84
+        $this->fireEventOn('end', [$handled, $job]);
85
+    }
86 86
 
87 87
 }
Please login to merge, or discard this patch.
src/Pipes/AbstractPipe.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	 * Set the dependencies.
21 21
 	 *
22 22
 	 * @author	Andrea Marco Sartori
23
-	 * @param	Illuminate\Contracts\Container\Container	$container
23
+	 * @param	Container	$container
24 24
 	 * @return	void
25 25
 	 */
26 26
 	public function __construct(Container $container)
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -10,117 +10,117 @@
 block discarded – undo
10 10
  */
11 11
 abstract class AbstractPipe {
12 12
 
13
-	/**
14
-	 * @author	Andrea Marco Sartori
15
-	 * @var		Illuminate\Contracts\Container\Container	$container	Service container.
16
-	 */
17
-	protected $container;
13
+    /**
14
+     * @author	Andrea Marco Sartori
15
+     * @var		Illuminate\Contracts\Container\Container	$container	Service container.
16
+     */
17
+    protected $container;
18 18
 	
19
-	/**
20
-	 * Set the dependencies.
21
-	 *
22
-	 * @author	Andrea Marco Sartori
23
-	 * @param	Illuminate\Contracts\Container\Container	$container
24
-	 * @return	void
25
-	 */
26
-	public function __construct(Container $container)
27
-	{
28
-		$this->container = $container;
29
-	}
19
+    /**
20
+     * Set the dependencies.
21
+     *
22
+     * @author	Andrea Marco Sartori
23
+     * @param	Illuminate\Contracts\Container\Container	$container
24
+     * @return	void
25
+     */
26
+    public function __construct(Container $container)
27
+    {
28
+        $this->container = $container;
29
+    }
30 30
 
31
-	/**
32
-	 * Handle the given job.
33
-	 *
34
-	 * @author	Andrea Marco Sartori
35
-	 * @param	mixed	$job
36
-	 * @param	Closure	$next
37
-	 * @return	mixed
38
-	 */
39
-	public function handle($job, Closure $next)
40
-	{
41
-		$this->callBefore($job);
31
+    /**
32
+     * Handle the given job.
33
+     *
34
+     * @author	Andrea Marco Sartori
35
+     * @param	mixed	$job
36
+     * @param	Closure	$next
37
+     * @return	mixed
38
+     */
39
+    public function handle($job, Closure $next)
40
+    {
41
+        $this->callBefore($job);
42 42
 
43
-		$handled = $next($job);
43
+        $handled = $next($job);
44 44
 
45
-		$this->callAfter($handled, $job);
45
+        $this->callAfter($handled, $job);
46 46
 
47
-		return $handled;
48
-	}
47
+        return $handled;
48
+    }
49 49
 
50
-	/**
51
-	 * Call the before method.
52
-	 *
53
-	 * @author	Andrea Marco Sartori
54
-	 * @param	Cerbero\Jobs\Job	$job
55
-	 * @return	void
56
-	 */
57
-	protected function callBefore($job)
58
-	{
59
-		$this->callIfExistsAndEnabled('before', [$job]);
60
-	}
50
+    /**
51
+     * Call the before method.
52
+     *
53
+     * @author	Andrea Marco Sartori
54
+     * @param	Cerbero\Jobs\Job	$job
55
+     * @return	void
56
+     */
57
+    protected function callBefore($job)
58
+    {
59
+        $this->callIfExistsAndEnabled('before', [$job]);
60
+    }
61 61
 
62
-	/**
63
-	 * Call and resolve depepndencies of a method if enabled.
64
-	 *
65
-	 * @author	Andrea Marco Sartori
66
-	 * @param	string	$method
67
-	 * @param	array	$parameters
68
-	 * @return	void
69
-	 */
70
-	private function callIfExistsAndEnabled($method, array $parameters = [])
71
-	{
72
-		if( ! $this->isEnabled()) return;
62
+    /**
63
+     * Call and resolve depepndencies of a method if enabled.
64
+     *
65
+     * @author	Andrea Marco Sartori
66
+     * @param	string	$method
67
+     * @param	array	$parameters
68
+     * @return	void
69
+     */
70
+    private function callIfExistsAndEnabled($method, array $parameters = [])
71
+    {
72
+        if( ! $this->isEnabled()) return;
73 73
 
74
-		if(method_exists($this, $method) && $this->{"{$method}IsEnabled"}())
75
-		{
76
-			$this->container->call([$this, $method], $parameters);
77
-		}
78
-	}
74
+        if(method_exists($this, $method) && $this->{"{$method}IsEnabled"}())
75
+        {
76
+            $this->container->call([$this, $method], $parameters);
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * Determine whether the whole pipe has to be processed.
82
-	 *
83
-	 * @author	Andrea Marco Sartori
84
-	 * @return	boolean
85
-	 */
86
-	protected function isEnabled()
87
-	{
88
-		return true;
89
-	}
80
+    /**
81
+     * Determine whether the whole pipe has to be processed.
82
+     *
83
+     * @author	Andrea Marco Sartori
84
+     * @return	boolean
85
+     */
86
+    protected function isEnabled()
87
+    {
88
+        return true;
89
+    }
90 90
 
91
-	/**
92
-	 * Call the after method.
93
-	 *
94
-	 * @author	Andrea Marco Sartori
95
-	 * @param	mixed	$handled
96
-	 * @param	Cerbero\Jobs\Job	$job
97
-	 * @return	void
98
-	 */
99
-	protected function callAfter($handled, $job)
100
-	{
101
-		$this->callIfExistsAndEnabled('after', [$handled, $job]);
102
-	}
91
+    /**
92
+     * Call the after method.
93
+     *
94
+     * @author	Andrea Marco Sartori
95
+     * @param	mixed	$handled
96
+     * @param	Cerbero\Jobs\Job	$job
97
+     * @return	void
98
+     */
99
+    protected function callAfter($handled, $job)
100
+    {
101
+        $this->callIfExistsAndEnabled('after', [$handled, $job]);
102
+    }
103 103
 
104
-	/**
105
-	 * Determine whether the before method has to be processed.
106
-	 *
107
-	 * @author	Andrea Marco Sartori
108
-	 * @return	boolean
109
-	 */
110
-	protected function beforeIsEnabled()
111
-	{
112
-		return true;
113
-	}
104
+    /**
105
+     * Determine whether the before method has to be processed.
106
+     *
107
+     * @author	Andrea Marco Sartori
108
+     * @return	boolean
109
+     */
110
+    protected function beforeIsEnabled()
111
+    {
112
+        return true;
113
+    }
114 114
 
115
-	/**
116
-	 * Determine whether the after method has to be processed.
117
-	 *
118
-	 * @author	Andrea Marco Sartori
119
-	 * @return	boolean
120
-	 */
121
-	protected function afterIsEnabled()
122
-	{
123
-		return true;
124
-	}
115
+    /**
116
+     * Determine whether the after method has to be processed.
117
+     *
118
+     * @author	Andrea Marco Sartori
119
+     * @return	boolean
120
+     */
121
+    protected function afterIsEnabled()
122
+    {
123
+        return true;
124
+    }
125 125
 
126 126
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,9 +69,9 @@
 block discarded – undo
69 69
 	 */
70 70
 	private function callIfExistsAndEnabled($method, array $parameters = [])
71 71
 	{
72
-		if( ! $this->isEnabled()) return;
72
+		if (!$this->isEnabled()) return;
73 73
 
74
-		if(method_exists($this, $method) && $this->{"{$method}IsEnabled"}())
74
+		if (method_exists($this, $method) && $this->{"{$method}IsEnabled"}())
75 75
 		{
76 76
 			$this->container->call([$this, $method], $parameters);
77 77
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@
 block discarded – undo
69 69
 	 */
70 70
 	private function callIfExistsAndEnabled($method, array $parameters = [])
71 71
 	{
72
-		if( ! $this->isEnabled()) return;
72
+		if( ! $this->isEnabled()) {
73
+		    return;
74
+		}
73 75
 
74 76
 		if(method_exists($this, $method) && $this->{"{$method}IsEnabled"}())
75 77
 		{
Please login to merge, or discard this patch.
src/Pipes/Login/Throttle.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * Run before the job is handled.
11 11
 	 *
12
-	 * @param	Cerbero\Auth\Services\Throttling\ThrottlerInterface	$throttler
12
+	 * @param	ThrottlerInterface	$throttler
13 13
 	 * @param	Cerbero\Auth\Jobs\LoginJob	$job
14 14
 	 * @return	mixed
15 15
 	 */
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Run after the handled job.
48 48
 	 *
49
-	 * @param	Cerbero\Auth\Services\Throttling\ThrottlerInterface	$throttler
49
+	 * @param	ThrottlerInterface	$throttler
50 50
 	 * @param	mixed	$handled
51 51
 	 * @param	Cerbero\Auth\Jobs\LoginJob	$job
52 52
 	 * @return	mixed
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -6,65 +6,65 @@
 block discarded – undo
6 6
 
7 7
 class Throttle extends AbstractPipe {
8 8
 
9
-	/**
10
-	 * Run before the job is handled.
11
-	 *
12
-	 * @param	Cerbero\Auth\Services\Throttling\ThrottlerInterface	$throttler
13
-	 * @param	Cerbero\Auth\Jobs\LoginJob	$job
14
-	 * @return	mixed
15
-	 */
16
-	public function before(ThrottlerInterface $throttler, $job)
17
-	{
18
-		$throttler->setSource($this->getSourceByJob($job));
9
+    /**
10
+     * Run before the job is handled.
11
+     *
12
+     * @param	Cerbero\Auth\Services\Throttling\ThrottlerInterface	$throttler
13
+     * @param	Cerbero\Auth\Jobs\LoginJob	$job
14
+     * @return	mixed
15
+     */
16
+    public function before(ThrottlerInterface $throttler, $job)
17
+    {
18
+        $throttler->setSource($this->getSourceByJob($job));
19 19
 
20
-		$throttler->incrementAttempts();
20
+        $throttler->incrementAttempts();
21 21
 
22
-		if($throttler->tooManyAttempts() || $throttler->lockedOut())
23
-		{
24
-			$throttler->lockOut();
22
+        if($throttler->tooManyAttempts() || $throttler->lockedOut())
23
+        {
24
+            $throttler->lockOut();
25 25
 
26
-			$seconds = $throttler->getRemainingSeconds();
26
+            $seconds = $throttler->getRemainingSeconds();
27 27
 
28
-			throw new DisplayException('auth::throttling.error', compact('seconds'));
29
-		}
30
-	}
28
+            throw new DisplayException('auth::throttling.error', compact('seconds'));
29
+        }
30
+    }
31 31
 
32
-	/**
33
-	 * Create source by using the given job.
34
-	 *
35
-	 * @author	Andrea Marco Sartori
36
-	 * @param	type	$job
37
-	 * @return	string
38
-	 */
39
-	private function getSourceByJob($job)
40
-	{
41
-		$login = head(array_except($job->credentials, 'password'));
32
+    /**
33
+     * Create source by using the given job.
34
+     *
35
+     * @author	Andrea Marco Sartori
36
+     * @param	type	$job
37
+     * @return	string
38
+     */
39
+    private function getSourceByJob($job)
40
+    {
41
+        $login = head(array_except($job->credentials, 'password'));
42 42
 
43
-		return $login . app('request')->ip();
44
-	}
43
+        return $login . app('request')->ip();
44
+    }
45 45
 
46
-	/**
47
-	 * Run after the handled job.
48
-	 *
49
-	 * @param	Cerbero\Auth\Services\Throttling\ThrottlerInterface	$throttler
50
-	 * @param	mixed	$handled
51
-	 * @param	Cerbero\Auth\Jobs\LoginJob	$job
52
-	 * @return	mixed
53
-	 */
54
-	public function after(ThrottlerInterface $throttler, $handled, $job)
55
-	{
56
-		$throttler->resetAttempts();
57
-	}
46
+    /**
47
+     * Run after the handled job.
48
+     *
49
+     * @param	Cerbero\Auth\Services\Throttling\ThrottlerInterface	$throttler
50
+     * @param	mixed	$handled
51
+     * @param	Cerbero\Auth\Jobs\LoginJob	$job
52
+     * @return	mixed
53
+     */
54
+    public function after(ThrottlerInterface $throttler, $handled, $job)
55
+    {
56
+        $throttler->resetAttempts();
57
+    }
58 58
 
59
-	/**
60
-	 * Determine whether the whole pipe has to be processed.
61
-	 *
62
-	 * @author	Andrea Marco Sartori
63
-	 * @return	boolean
64
-	 */
65
-	protected function isEnabled()
66
-	{
67
-		return config('_auth.login.throttling.enabled');
68
-	}
59
+    /**
60
+     * Determine whether the whole pipe has to be processed.
61
+     *
62
+     * @author	Andrea Marco Sartori
63
+     * @return	boolean
64
+     */
65
+    protected function isEnabled()
66
+    {
67
+        return config('_auth.login.throttling.enabled');
68
+    }
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
 		$throttler->incrementAttempts();
21 21
 
22
-		if($throttler->tooManyAttempts() || $throttler->lockedOut())
22
+		if ($throttler->tooManyAttempts() || $throttler->lockedOut())
23 23
 		{
24 24
 			$throttler->lockOut();
25 25
 
Please login to merge, or discard this patch.
src/Pipes/Register/Login.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 	/**
9 9
 	 * Run after the handled job.
10 10
 	 *
11
-	 * @param	Illuminate\Contracts\Auth\Guard	$auth
11
+	 * @param	Guard	$auth
12 12
 	 * @param	mixed	$handled
13 13
 	 * @param	Cerbero\Auth\Jobs\LoginJob	$job
14 14
 	 * @return	mixed
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@
 block discarded – undo
5 5
 
6 6
 class Login extends AbstractPipe {
7 7
 
8
-	/**
9
-	 * Run after the handled job.
10
-	 *
11
-	 * @param	Illuminate\Contracts\Auth\Guard	$auth
12
-	 * @param	mixed	$handled
13
-	 * @param	Cerbero\Auth\Jobs\LoginJob	$job
14
-	 * @return	mixed
15
-	 */
16
-	public function after(Guard $auth, $handled, $job)
17
-	{
18
-		$auth->login($handled);
19
-	}
8
+    /**
9
+     * Run after the handled job.
10
+     *
11
+     * @param	Illuminate\Contracts\Auth\Guard	$auth
12
+     * @param	mixed	$handled
13
+     * @param	Cerbero\Auth\Jobs\LoginJob	$job
14
+     * @return	mixed
15
+     */
16
+    public function after(Guard $auth, $handled, $job)
17
+    {
18
+        $auth->login($handled);
19
+    }
20 20
 
21
-	/**
22
-	 * Determine whether the after method has to be processed.
23
-	 *
24
-	 * @author	Andrea Marco Sartori
25
-	 * @return	boolean
26
-	 */
27
-	protected function afterIsEnabled()
28
-	{
29
-		return config('_auth.register.login_after_registering');
30
-	}
21
+    /**
22
+     * Determine whether the after method has to be processed.
23
+     *
24
+     * @author	Andrea Marco Sartori
25
+     * @return	boolean
26
+     */
27
+    protected function afterIsEnabled()
28
+    {
29
+        return config('_auth.register.login_after_registering');
30
+    }
31 31
 
32 32
 }
Please login to merge, or discard this patch.
src/Pipes/Register/Notify.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	/**
39 39
 	 * Run after the handled job.
40 40
 	 *
41
-	 * @param	Illuminate\Contracts\Mail\Mailer	$mailer
41
+	 * @param	Mailer	$mailer
42 42
 	 * @param	mixed	$handled
43 43
 	 * @param	Cerbero\Auth\Jobs\RegisterJob	$job
44 44
 	 * @return	mixed
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -5,67 +5,67 @@
 block discarded – undo
5 5
 
6 6
 class Notify extends AbstractPipe {
7 7
 
8
-	/**
9
-	 * @author	Andrea Marco Sartori
10
-	 * @var		string	$password	Generated password.
11
-	 */
12
-	protected $password = null;
8
+    /**
9
+     * @author	Andrea Marco Sartori
10
+     * @var		string	$password	Generated password.
11
+     */
12
+    protected $password = null;
13 13
 
14
-	/**
15
-	 * Run before the job is handled.
16
-	 *
17
-	 * @param	Cerbero\Auth\Jobs\RegisterJob	$job
18
-	 * @return	mixed
19
-	 */
20
-	public function before($job)
21
-	{
22
-		$this->password = str_random(8);
14
+    /**
15
+     * Run before the job is handled.
16
+     *
17
+     * @param	Cerbero\Auth\Jobs\RegisterJob	$job
18
+     * @return	mixed
19
+     */
20
+    public function before($job)
21
+    {
22
+        $this->password = str_random(8);
23 23
 
24
-		$job->attributes['password'] = $this->password;
25
-	}
24
+        $job->attributes['password'] = $this->password;
25
+    }
26 26
 
27
-	/**
28
-	 * Determine whether the before method has to be processed.
29
-	 *
30
-	 * @author	Andrea Marco Sartori
31
-	 * @return	boolean
32
-	 */
33
-	protected function beforeIsEnabled()
34
-	{
35
-		return config('_auth.register.email.generate_password_for_user');
36
-	}
27
+    /**
28
+     * Determine whether the before method has to be processed.
29
+     *
30
+     * @author	Andrea Marco Sartori
31
+     * @return	boolean
32
+     */
33
+    protected function beforeIsEnabled()
34
+    {
35
+        return config('_auth.register.email.generate_password_for_user');
36
+    }
37 37
 
38
-	/**
39
-	 * Run after the handled job.
40
-	 *
41
-	 * @param	Illuminate\Contracts\Mail\Mailer	$mailer
42
-	 * @param	mixed	$handled
43
-	 * @param	Cerbero\Auth\Jobs\RegisterJob	$job
44
-	 * @return	mixed
45
-	 */
46
-	public function after(Mailer $mailer, $handled, $job)
47
-	{
48
-		$email = $handled->email;
38
+    /**
39
+     * Run after the handled job.
40
+     *
41
+     * @param	Illuminate\Contracts\Mail\Mailer	$mailer
42
+     * @param	mixed	$handled
43
+     * @param	Cerbero\Auth\Jobs\RegisterJob	$job
44
+     * @return	mixed
45
+     */
46
+    public function after(Mailer $mailer, $handled, $job)
47
+    {
48
+        $email = $handled->email;
49 49
 
50
-		$payload = ['user' => $handled, 'password' => $this->password];
50
+        $payload = ['user' => $handled, 'password' => $this->password];
51 51
 
52
-		$method = config('_auth.register.email.queue') ? 'queue' : 'send';
52
+        $method = config('_auth.register.email.queue') ? 'queue' : 'send';
53 53
 
54
-		$mailer->$method(config('_auth.register.email.view'), $payload, function($message) use($email)
55
-		{
56
-			$message->to($email)->subject(trans('auth::register.email_subject'));
57
-		});
58
-	}
54
+        $mailer->$method(config('_auth.register.email.view'), $payload, function($message) use($email)
55
+        {
56
+            $message->to($email)->subject(trans('auth::register.email_subject'));
57
+        });
58
+    }
59 59
 
60
-	/**
61
-	 * Determine whether the after method has to be processed.
62
-	 *
63
-	 * @author	Andrea Marco Sartori
64
-	 * @return	boolean
65
-	 */
66
-	protected function afterIsEnabled()
67
-	{
68
-		return config('_auth.register.email.send');
69
-	}
60
+    /**
61
+     * Determine whether the after method has to be processed.
62
+     *
63
+     * @author	Andrea Marco Sartori
64
+     * @return	boolean
65
+     */
66
+    protected function afterIsEnabled()
67
+    {
68
+        return config('_auth.register.email.send');
69
+    }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
src/Repositories/EloquentUserRepository.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 	 * @author	Andrea Marco Sartori
74 74
 	 * @param	User	$user
75 75
 	 * @param	string	$password
76
-	 * @return	boolean
76
+	 * @return	boolean|null
77 77
 	 */
78 78
 	public function resetPassword($user, $password)
79 79
 	{
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -7,81 +7,81 @@
 block discarded – undo
7 7
  */
8 8
 class EloquentUserRepository implements UserRepositoryInterface {
9 9
 
10
-	/**
11
-	 * @author	Andrea Marco Sartori
12
-	 * @var		User	$user	User model.
13
-	 */
14
-	protected $user;
10
+    /**
11
+     * @author	Andrea Marco Sartori
12
+     * @var		User	$user	User model.
13
+     */
14
+    protected $user;
15 15
 	
16
-	/**
17
-	 * Set the dependencies.
18
-	 *
19
-	 * @author	Andrea Marco Sartori
20
-	 * @return	void
21
-	 */
22
-	public function __construct()
23
-	{
24
-		$user = config('auth.model');
16
+    /**
17
+     * Set the dependencies.
18
+     *
19
+     * @author	Andrea Marco Sartori
20
+     * @return	void
21
+     */
22
+    public function __construct()
23
+    {
24
+        $user = config('auth.model');
25 25
 
26
-		$this->user = new $user;
27
-	}
26
+        $this->user = new $user;
27
+    }
28 28
 
29
-	/**
30
-	 * Register a new user.
31
-	 *
32
-	 * @author	Andrea Marco Sartori
33
-	 * @param	array	$attributes
34
-	 * @return	User
35
-	 */
36
-	public function register(array $attributes)
37
-	{
38
-		return $this->user->create($attributes);
39
-	}
29
+    /**
30
+     * Register a new user.
31
+     *
32
+     * @author	Andrea Marco Sartori
33
+     * @param	array	$attributes
34
+     * @return	User
35
+     */
36
+    public function register(array $attributes)
37
+    {
38
+        return $this->user->create($attributes);
39
+    }
40 40
 
41
-	/**
42
-	 * Assign a token to reset the password of the user with the given email.
43
-	 *
44
-	 * @author	Andrea Marco Sartori
45
-	 * @param	string	$token
46
-	 * @param	string	$email
47
-	 * @return	void
48
-	 */
49
-	public function assignResetToken($token, $email)
50
-	{
51
-		$user = $this->user->whereEmail($email)->first();
41
+    /**
42
+     * Assign a token to reset the password of the user with the given email.
43
+     *
44
+     * @author	Andrea Marco Sartori
45
+     * @param	string	$token
46
+     * @param	string	$email
47
+     * @return	void
48
+     */
49
+    public function assignResetToken($token, $email)
50
+    {
51
+        $user = $this->user->whereEmail($email)->first();
52 52
 
53
-		$user->reset_token = $token;
53
+        $user->reset_token = $token;
54 54
 
55
-		$user->save();
56
-	}
55
+        $user->save();
56
+    }
57 57
 
58
-	/**
59
-	 * Retrieve the user with the given reset token.
60
-	 *
61
-	 * @author	Andrea Marco Sartori
62
-	 * @param	string	$token
63
-	 * @return	User|null
64
-	 */
65
-	public function findByResetToken($token)
66
-	{
67
-		return $this->user->whereResetToken($token)->first();
68
-	}
58
+    /**
59
+     * Retrieve the user with the given reset token.
60
+     *
61
+     * @author	Andrea Marco Sartori
62
+     * @param	string	$token
63
+     * @return	User|null
64
+     */
65
+    public function findByResetToken($token)
66
+    {
67
+        return $this->user->whereResetToken($token)->first();
68
+    }
69 69
 
70
-	/**
71
-	 * Reset the password of the given user.
72
-	 *
73
-	 * @author	Andrea Marco Sartori
74
-	 * @param	User	$user
75
-	 * @param	string	$password
76
-	 * @return	boolean
77
-	 */
78
-	public function resetPassword($user, $password)
79
-	{
80
-		$user->password = $password;
70
+    /**
71
+     * Reset the password of the given user.
72
+     *
73
+     * @author	Andrea Marco Sartori
74
+     * @param	User	$user
75
+     * @param	string	$password
76
+     * @return	boolean
77
+     */
78
+    public function resetPassword($user, $password)
79
+    {
80
+        $user->password = $password;
81 81
 
82
-		$user->reset_token = null;
82
+        $user->reset_token = null;
83 83
 
84
-		$user->save();
85
-	}
84
+        $user->save();
85
+    }
86 86
 
87 87
 }
Please login to merge, or discard this patch.
src/Services/Throttling/CachingThrottler.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * Set the dependencies.
35 35
 	 *
36 36
 	 * @author	Andrea Marco Sartori
37
-	 * @param	Illuminate\Contracts\Cache\Repository	$cache
37
+	 * @param	Cache	$cache
38 38
 	 * @return	void
39 39
 	 */
40 40
 	public function __construct(Cache $cache)
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * Set univocal source where attempts come from.
47 47
 	 *
48 48
 	 * @author	Andrea Marco Sartori
49
-	 * @return	boolean
49
+	 * @return	boolean|null
50 50
 	 */
51 51
 	public function setSource($source)
52 52
 	{
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,141 +12,141 @@
 block discarded – undo
12 12
 class CachingThrottler implements ThrottlerInterface
13 13
 {
14 14
 
15
-	/**
16
-	 * @author	Andrea Marco Sartori
17
-	 * @var		Illuminate\Contracts\Cache\Repository	$cache	Cache repository.
18
-	 */
19
-	protected $cache;
20
-
21
-	/**
22
-	 * @author	Andrea Marco Sartori
23
-	 * @var		string	$key	Source where attempts come from.
24
-	 */
25
-	protected $key;
26
-
27
-	/**
28
-	 * @author	Andrea Marco Sartori
29
-	 * @var		string	$lockOutKey	Key to store lock out time in.
30
-	 */
31
-	protected $lockOutKey;
15
+    /**
16
+     * @author	Andrea Marco Sartori
17
+     * @var		Illuminate\Contracts\Cache\Repository	$cache	Cache repository.
18
+     */
19
+    protected $cache;
20
+
21
+    /**
22
+     * @author	Andrea Marco Sartori
23
+     * @var		string	$key	Source where attempts come from.
24
+     */
25
+    protected $key;
26
+
27
+    /**
28
+     * @author	Andrea Marco Sartori
29
+     * @var		string	$lockOutKey	Key to store lock out time in.
30
+     */
31
+    protected $lockOutKey;
32 32
 	
33
-	/**
34
-	 * Set the dependencies.
35
-	 *
36
-	 * @author	Andrea Marco Sartori
37
-	 * @param	Illuminate\Contracts\Cache\Repository	$cache
38
-	 * @return	void
39
-	 */
40
-	public function __construct(Cache $cache)
41
-	{
42
-		$this->cache = $cache;
43
-	}
44
-
45
-	/**
46
-	 * Set univocal source where attempts come from.
47
-	 *
48
-	 * @author	Andrea Marco Sartori
49
-	 * @return	boolean
50
-	 */
51
-	public function setSource($source)
52
-	{
53
-		$this->key = $source;
54
-
55
-		$this->lockOutKey = "{$source}:lockout";
56
-	}
57
-
58
-	/**
59
-	 * Determine whether the user has been locked out.
60
-	 *
61
-	 * @author	Andrea Marco Sartori
62
-	 * @return	boolean
63
-	 */
64
-	public function lockedOut()
65
-	{
66
-		return $this->cache->has($this->lockOutKey);
67
-	}
68
-
69
-	/**
70
-	 * Retrieve the number of remaining seconds before the next attempt.
71
-	 *
72
-	 * @author	Andrea Marco Sartori
73
-	 * @return	integer
74
-	 */
75
-	public function getRemainingSeconds()
76
-	{
77
-		return $this->cache->get($this->lockOutKey) - time();
78
-	}
79
-
80
-	/**
81
-	 * Increment the number of failed attempts.
82
-	 *
83
-	 * @author	Andrea Marco Sartori
84
-	 * @return	void
85
-	 */
86
-	public function incrementAttempts()
87
-	{
88
-		$this->cache->add($this->key, 0, $this->getExpiry());
89
-
90
-		$this->cache->increment($this->key);
91
-	}
92
-
93
-	/**
94
-	 * Retrieve the minutes after which keys expire.
95
-	 *
96
-	 * @author	Andrea Marco Sartori
97
-	 * @return	integer
98
-	 */
99
-	private function getExpiry()
100
-	{
101
-		return (int) $this->getDelay() / 60;
102
-	}
103
-
104
-	/**
105
-	 * Retrieve the seconds to wait before the next attempt.
106
-	 *
107
-	 * @author	Andrea Marco Sartori
108
-	 * @return	integer
109
-	 */
110
-	private function getDelay()
111
-	{
112
-		return config('_auth.login.throttling.delay');
113
-	}
114
-
115
-	/**
116
-	 * Determine whether a user has performed too many attempts.
117
-	 *
118
-	 * @author	Andrea Marco Sartori
119
-	 * @return	boolean
120
-	 */
121
-	public function tooManyAttempts()
122
-	{
123
-		$maximum = config('_auth.login.throttling.max_attempts');
124
-
125
-		return $this->cache->get($this->key, 0) > $maximum;
126
-	}
127
-
128
-	/**
129
-	 * Lock a user out.
130
-	 *
131
-	 * @author	Andrea Marco Sartori
132
-	 * @return	void
133
-	 */
134
-	public function lockOut()
135
-	{
136
-		$this->resetAttempts();
137
-
138
-		$this->cache->add($this->lockOutKey, $this->getDelay() + time(), $this->getExpiry());
139
-	}
140
-
141
-	/**
142
-	 * Reset the attempts counter.
143
-	 *
144
-	 * @author	Andrea Marco Sartori
145
-	 * @return	void
146
-	 */
147
-	public function resetAttempts()
148
-	{
149
-		$this->cache->forget($this->key);
150
-	}
33
+    /**
34
+     * Set the dependencies.
35
+     *
36
+     * @author	Andrea Marco Sartori
37
+     * @param	Illuminate\Contracts\Cache\Repository	$cache
38
+     * @return	void
39
+     */
40
+    public function __construct(Cache $cache)
41
+    {
42
+        $this->cache = $cache;
43
+    }
44
+
45
+    /**
46
+     * Set univocal source where attempts come from.
47
+     *
48
+     * @author	Andrea Marco Sartori
49
+     * @return	boolean
50
+     */
51
+    public function setSource($source)
52
+    {
53
+        $this->key = $source;
54
+
55
+        $this->lockOutKey = "{$source}:lockout";
56
+    }
57
+
58
+    /**
59
+     * Determine whether the user has been locked out.
60
+     *
61
+     * @author	Andrea Marco Sartori
62
+     * @return	boolean
63
+     */
64
+    public function lockedOut()
65
+    {
66
+        return $this->cache->has($this->lockOutKey);
67
+    }
68
+
69
+    /**
70
+     * Retrieve the number of remaining seconds before the next attempt.
71
+     *
72
+     * @author	Andrea Marco Sartori
73
+     * @return	integer
74
+     */
75
+    public function getRemainingSeconds()
76
+    {
77
+        return $this->cache->get($this->lockOutKey) - time();
78
+    }
79
+
80
+    /**
81
+     * Increment the number of failed attempts.
82
+     *
83
+     * @author	Andrea Marco Sartori
84
+     * @return	void
85
+     */
86
+    public function incrementAttempts()
87
+    {
88
+        $this->cache->add($this->key, 0, $this->getExpiry());
89
+
90
+        $this->cache->increment($this->key);
91
+    }
92
+
93
+    /**
94
+     * Retrieve the minutes after which keys expire.
95
+     *
96
+     * @author	Andrea Marco Sartori
97
+     * @return	integer
98
+     */
99
+    private function getExpiry()
100
+    {
101
+        return (int) $this->getDelay() / 60;
102
+    }
103
+
104
+    /**
105
+     * Retrieve the seconds to wait before the next attempt.
106
+     *
107
+     * @author	Andrea Marco Sartori
108
+     * @return	integer
109
+     */
110
+    private function getDelay()
111
+    {
112
+        return config('_auth.login.throttling.delay');
113
+    }
114
+
115
+    /**
116
+     * Determine whether a user has performed too many attempts.
117
+     *
118
+     * @author	Andrea Marco Sartori
119
+     * @return	boolean
120
+     */
121
+    public function tooManyAttempts()
122
+    {
123
+        $maximum = config('_auth.login.throttling.max_attempts');
124
+
125
+        return $this->cache->get($this->key, 0) > $maximum;
126
+    }
127
+
128
+    /**
129
+     * Lock a user out.
130
+     *
131
+     * @author	Andrea Marco Sartori
132
+     * @return	void
133
+     */
134
+    public function lockOut()
135
+    {
136
+        $this->resetAttempts();
137
+
138
+        $this->cache->add($this->lockOutKey, $this->getDelay() + time(), $this->getExpiry());
139
+    }
140
+
141
+    /**
142
+     * Reset the attempts counter.
143
+     *
144
+     * @author	Andrea Marco Sartori
145
+     * @return	void
146
+     */
147
+    public function resetAttempts()
148
+    {
149
+        $this->cache->forget($this->key);
150
+    }
151 151
 
152 152
 }
Please login to merge, or discard this patch.