ThrottleRequestsService   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 7
eloc 12
c 2
b 1
f 0
dl 0
loc 40
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A _limiter() 0 3 1
A _throttleKey() 0 3 1
A _fireLockoutEvent() 0 3 1
A hasTooManyAttempts() 0 3 1
A incrementAttempts() 0 3 1
A __construct() 0 4 1
A clearAttempts() 0 3 1
1
<?php
2
3
namespace Ikechukwukalu\Requirepin\Services;
4
5
use Illuminate\Foundation\Auth\AuthenticatesUsers;
6
use Illuminate\Http\Request;
7
8
class ThrottleRequestsService {
9
    use AuthenticatesUsers;
0 ignored issues
show
introduced by
The trait Illuminate\Foundation\Auth\AuthenticatesUsers requires some properties which are not provided by Ikechukwukalu\Requirepin...ThrottleRequestsService: $redirectTo, $decayMinutes
Loading history...
10
11
    public $maxAttempts = 5; // change to the max attempt you want.
12
    public $delayMinutes = 1;
13
14
    public function __construct(int $maxAttempts = 5, int $delayMinutes = 1)
15
    {
16
        $this->maxAttempts = $maxAttempts;
17
        $this->delayMinutes = $delayMinutes;
18
    }
19
20
    public function hasTooManyAttempts (Request $request)
21
    {
22
        return $this->hasTooManyLoginAttempts($request);
23
    }
24
25
    public function incrementAttempts (Request $request)
26
    {
27
        return $this->incrementLoginAttempts($request);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->incrementLoginAttempts($request) targeting Ikechukwukalu\Requirepin...ncrementLoginAttempts() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
    }
29
30
    public function clearAttempts (Request $request)
31
    {
32
        return $this->clearLoginAttempts($request);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->clearLoginAttempts($request) targeting Ikechukwukalu\Requirepin...e::clearLoginAttempts() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
33
    }
34
35
    public function _fireLockoutEvent (Request $request)
36
    {
37
        return $this->fireLockoutEvent($request);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->fireLockoutEvent($request) targeting Ikechukwukalu\Requirepin...ice::fireLockoutEvent() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
    }
39
40
    public function _limiter ()
41
    {
42
        return $this->limiter();
43
    }
44
45
    public function _throttleKey (Request $request)
46
    {
47
        return $this->throttleKey($request);
48
    }
49
}
50