8
8
9
9
namespace PHPViet \Validation \Rules ;
10
10
11
- use IPLib \Address \AddressInterface as IpInterface ;
12
- use IPLib \Address \Type as IpType ;
13
11
use IPLib \Factory as IpFactory ;
14
- use Respect \ Validation \ Exceptions \ ComponentException ;
12
+ use IPLib \ Address \ Type as IpType ;
15
13
use Respect \Validation \Rules \AbstractRule ;
14
+ use IPLib \Address \AddressInterface as IpInterface ;
15
+ use Respect \Validation \Exceptions \ComponentException ;
16
16
17
17
/**
18
18
* @author Vuong Minh <[email protected] >
@@ -28,7 +28,7 @@ class IpVN extends AbstractRule
28
28
29
29
public function __construct (?int $ version = null )
30
30
{
31
- if (null !== $ version && !$ this ->isSupportedVersion ($ version )) {
31
+ if (null !== $ version && ! $ this ->isSupportedVersion ($ version )) {
32
32
throw new ComponentException (sprintf ('Only versions %d, %d are supported: %d given ' , self ::IPV4 , self ::IPV6 , $ version ));
33
33
}
34
34
@@ -37,15 +37,15 @@ public function __construct(?int $version = null)
37
37
38
38
public function validate ($ input ): bool
39
39
{
40
- if (!$ ip = IpFactory::addressFromString ($ input )) {
40
+ if (! $ ip = IpFactory::addressFromString ($ input )) {
41
41
return false ;
42
42
}
43
43
44
44
if (($ version = $ ip ->getAddressType ()) !== $ this ->version && null !== $ this ->version ) {
45
45
return false ;
46
46
}
47
47
48
- if (!$ ranges = $ this ->getIpRanges ($ input , $ version )) {
48
+ if (! $ ranges = $ this ->getIpRanges ($ input , $ version )) {
49
49
return false ;
50
50
}
51
51
@@ -62,7 +62,7 @@ protected function getIpRanges(string $ip, int $version): ?array
62
62
$ map = static ::getIpV6Range ();
63
63
}
64
64
65
- while (!is_null ($ key = array_shift ($ keys ))) {
65
+ while (! is_null ($ key = array_shift ($ keys ))) {
66
66
if (isset ($ map [$ key ])) {
67
67
$ map = $ map [$ key ];
68
68
@@ -93,7 +93,7 @@ protected static function getIpV4Range(): array
93
93
static $ range = null ;
94
94
95
95
if (null === $ range ) {
96
- $ range = require __DIR__ . '/../../resources/ip-v4-range.php ' ;
96
+ $ range = require __DIR__ . '/../../resources/ip-v4-range.php ' ;
97
97
}
98
98
99
99
return $ range ;
@@ -104,7 +104,7 @@ protected static function getIpV6Range(): array
104
104
static $ range = null ;
105
105
106
106
if (null === $ range ) {
107
- $ range = require __DIR__ . '/../../resources/ip-v6-range.php ' ;
107
+ $ range = require __DIR__ . '/../../resources/ip-v6-range.php ' ;
108
108
}
109
109
110
110
return $ range ;
0 commit comments