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