Conditions | 5 |
Paths | 8 |
Total Lines | 58 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
16 | public static function checkBlocked() |
||
17 | { |
||
18 | $requestIp = Request::ip(); |
||
19 | $all = Request::all(); |
||
20 | $method = Request::method(); |
||
21 | $route = Request::route(); |
||
22 | $ipAddressDetails = IpAddressDetails::checkIP($requestIp); |
||
23 | $blocked = false; |
||
24 | $type = null; |
||
25 | |||
26 | // Check IP |
||
27 | $blocked = self::checkedBlockedList($requestIp, $blocked); |
||
28 | |||
29 | // Check Ip Address Details |
||
30 | if ($ipAddressDetails) { |
||
31 | // Check City |
||
32 | $blocked = self::checkedBlockedList($ipAddressDetails['city'], $blocked); |
||
33 | |||
34 | // Check State |
||
35 | $blocked = self::checkedBlockedList($ipAddressDetails['state'], $blocked); |
||
36 | |||
37 | // Check Country |
||
38 | $blocked = self::checkedBlockedList($ipAddressDetails['country'], $blocked); |
||
39 | |||
40 | // Check Country Code |
||
41 | $blocked = self::checkedBlockedList($ipAddressDetails['countryCode'], $blocked); |
||
42 | |||
43 | // Check Continent |
||
44 | $blocked = self::checkedBlockedList($ipAddressDetails['continent'], $blocked); |
||
45 | |||
46 | // Check Continent |
||
47 | $blocked = self::checkedBlockedList($ipAddressDetails['continent'], $blocked); |
||
48 | |||
49 | // Check Region |
||
50 | $blocked = self::checkedBlockedList($ipAddressDetails['region'], $blocked); |
||
51 | |||
52 | $type = 'ip'; |
||
53 | } |
||
54 | |||
55 | // Registering |
||
56 | if ($method === 'POST' && $route->uri === 'register') { |
||
57 | $domain_name = self::getEmailDomain($all['email']); |
||
58 | $blocked = self::checkedBlockedList($domain_name, $blocked); |
||
59 | $blocked = self::checkedBlockedList($all['email'], $blocked); |
||
60 | $type = 'register'; |
||
61 | } |
||
62 | |||
63 | // Logged IN |
||
64 | if (\Auth::check()) { |
||
65 | $userId = Request::user()->id; |
||
|
|||
66 | $userEmail = Request::user()->email; |
||
67 | $domain_name = self::getEmailDomain($userEmail); |
||
68 | $blocked = self::checkedBlockedList($domain_name, $blocked); |
||
69 | $blocked = self::checkedBlockedList($userEmail, $blocked); |
||
70 | $type = 'auth'; |
||
71 | } |
||
72 | |||
73 | self::checkBlockedActions($blocked, $type); |
||
74 | } |
||
150 |