| Conditions | 25 |
| Paths | 15 |
| Total Lines | 94 |
| Code Lines | 58 |
| 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 |
||
| 29 | public function processRules($domain, $headers) |
||
| 30 | { |
||
| 31 | if ($headers['0'] == 'HTTP/1.0 200 OK' || $headers['0'] == 'HTTP/1.1 200 OK') { |
||
| 32 | |||
| 33 | $final_header_status = 'Live Site (200)'; |
||
| 34 | $header_data = 'n/a'; |
||
| 35 | $final_destination = 'http://' . $domain; |
||
| 36 | $final_destination_apex = $domain; |
||
| 37 | |||
| 38 | } elseif ($headers['0'] == 'HTTP/1.0 301 Moved Permanently' || $headers['0'] == 'HTTP/1.1 301 Moved Permanently') { |
||
| 39 | |||
| 40 | list($header_data, $final_destination, $final_destination_apex, $count) = $this->createData($domain, $headers); |
||
| 41 | |||
| 42 | if ($count === 1) { |
||
| 43 | $header_status = 'Redirect, Permanent (301)'; |
||
| 44 | } elseif ($count > 1) { |
||
| 45 | $header_status = 'Redirect, Permanent (301) [Multiple Redirects]'; |
||
| 46 | } |
||
| 47 | |||
| 48 | $final_header_status = $this->checkSameRedirects($domain, $header_status, $header_data); |
||
| 49 | |||
| 50 | } elseif ($headers['0'] == 'HTTP/1.0 302 Found' || $headers['0'] == 'HTTP/1.1 302 Found' || $headers['0'] == 'HTTP/1.1 302 Moved Temporarily') { |
||
| 51 | |||
| 52 | list($header_data, $final_destination, $final_destination_apex, $count) = $this->createData($domain, $headers); |
||
| 53 | |||
| 54 | if ($count === 1) { |
||
| 55 | $header_status = 'Redirect, Temporary (302)'; |
||
| 56 | } elseif ($count > 1) { |
||
| 57 | $header_status = 'Redirect, Temporary (302) [Multiple Redirects]'; |
||
| 58 | } |
||
| 59 | |||
| 60 | $final_header_status = $this->checkSameRedirects($domain, $header_status, $header_data); |
||
| 61 | |||
| 62 | } elseif ($headers['0'] == 'HTTP/1.0 400 Bad Request') { |
||
| 63 | |||
| 64 | $final_header_status = 'Bad Request (400)'; |
||
| 65 | $header_data = 'n/a'; |
||
| 66 | $final_destination = 'n/a'; |
||
| 67 | $final_destination_apex = 'n/a'; |
||
| 68 | |||
| 69 | } elseif ($headers['0'] == 'HTTP/1.1 403 Forbidden') { |
||
| 70 | |||
| 71 | $final_header_status = 'Forbidden (403)'; |
||
| 72 | $header_data = 'n/a'; |
||
| 73 | $final_destination = 'n/a'; |
||
| 74 | $final_destination_apex = 'n/a'; |
||
| 75 | |||
| 76 | } elseif ($headers['0'] == 'HTTP/1.0 404 Not Found' || $headers['0'] == 'HTTP/1.1 404 Not Found') { |
||
| 77 | |||
| 78 | $final_header_status = 'Not Found (404)'; |
||
| 79 | $header_data = 'n/a'; |
||
| 80 | $final_destination = 'n/a'; |
||
| 81 | $final_destination_apex = 'n/a'; |
||
| 82 | |||
| 83 | } elseif ($headers['0'] == 'HTTP/1.1 463' || $headers['0'] == 'HTTP/1.1 463 ') { |
||
| 84 | |||
| 85 | $final_header_status = 'Unspecified Error (463)'; |
||
| 86 | $header_data = 'n/a'; |
||
| 87 | $final_destination = 'n/a'; |
||
| 88 | $final_destination_apex = 'n/a'; |
||
| 89 | |||
| 90 | } elseif ($headers['0'] == 'HTTP/1.0 500 Internal Server Error' || $headers['0'] == 'HTTP/1.1 500 Internal Server Error') { |
||
| 91 | |||
| 92 | $final_header_status = 'Internal Server Error (500)'; |
||
| 93 | $header_data = 'n/a'; |
||
| 94 | $final_destination = 'n/a'; |
||
| 95 | $final_destination_apex = 'n/a'; |
||
| 96 | |||
| 97 | } elseif ($headers['0'] == 'HTTP/1.0 503 Service Unavailable' || $headers['0'] == 'HTTP/1.1 503 Service Unavailable' || $headers['0'] == 'HTTP/1.1 503 Service Temporarily Unavailable') { |
||
| 98 | |||
| 99 | $final_header_status = 'Service Temporarily Unavailable (503)'; |
||
| 100 | $header_data = 'n/a'; |
||
| 101 | $final_destination = 'n/a'; |
||
| 102 | $final_destination_apex = 'n/a'; |
||
| 103 | |||
| 104 | } else { |
||
| 105 | |||
| 106 | if (!$headers['0'] || $headers['0'] == '') { |
||
| 107 | |||
| 108 | $final_header_status = 'Error Retrieving Headers'; |
||
| 109 | |||
| 110 | } else { |
||
| 111 | |||
| 112 | $final_header_status = $headers['0']; |
||
| 113 | |||
| 114 | } |
||
| 115 | |||
| 116 | $header_data = 'n/a'; |
||
| 117 | $final_destination = 'n/a'; |
||
| 118 | $final_destination_apex = 'n/a'; |
||
| 119 | |||
| 120 | } |
||
| 121 | |||
| 122 | return array($final_header_status, $header_data, $final_destination, $final_destination_apex); |
||
| 123 | } |
||
| 189 |