Whitelist   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A inRange() 0 9 3
1
<?php namespace WITR\Services;
2
3
use Closure;
4
use Illuminate\Contracts\Auth\Guard;
5
6
class Whitelist {
7
8
	protected $fromIp;
9
	protected $toIp;
10
11
	/**
12
	 * Create a new filter instance.
13
	 *
14
	 * @param  Guard  $auth
0 ignored issues
show
Bug introduced by
There is no parameter named $auth. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
15
	 * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
16
	 */
17
	public function __construct($fromIp, $toIp)
18
	{
19
		$this->fromIp = $fromIp;
20
		$this->toIp = $toIp;
21
	}
22
23
	/**
24
	 * Handle an incoming request.
25
	 *
26
	 * @param  \Illuminate\Http\Request  $request
27
	 * @param  \Closure  $next
0 ignored issues
show
Bug introduced by
There is no parameter named $next. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
28
	 * @return mixed
29
	 */
30
	public function inRange($request)
31
	{
32
		$ip = $request->getClientIp();
33
		if( (ip2long($this->fromIp) <= ip2long($ip)) && (ip2long($ip) <= ip2long($this->toIp))) {
34
			return true;
35
		} else {
36
			return false;
37
		}
38
	}
39
40
}
41