Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | 6 | public static function fromIp($ip) |
|
15 | { |
||
16 | 6 | if (starts_with($ip, '192.168.')) { |
|
17 | 6 | return '192.168.0.0/16'; |
|
18 | } |
||
19 | |||
20 | 1 | if (starts_with($ip, '10.')) { |
|
21 | 1 | return '10.0.0.0/8'; |
|
22 | } |
||
23 | |||
24 | 1 | if (preg_match('/^172\.(1[6-9]|2[0-9]|3[01])\./', $ip)) { |
|
25 | 1 | return '172.16.0.0/12'; |
|
26 | } |
||
27 | |||
28 | 1 | return 'Internet'; |
|
29 | } |
||
30 | } |
||
31 |