| Conditions | 10 |
| Paths | 5 |
| Total Lines | 58 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 71 | function displayPHPError($erreurType, $err_msg, $err_file, $err_line, $backtrace) |
||
| 72 | { |
||
| 73 | ob_clean(); |
||
| 74 | echo ' |
||
| 75 | <!doctype html> |
||
| 76 | <html lang="fr"> |
||
| 77 | <head> |
||
| 78 | <title>Une erreur est parmi nous !</title> |
||
| 79 | <style> |
||
| 80 | html {padding:0; margin:0; background-color:#e3e3e3; font-family:sans-serif; font-size: 1em; word-wrap:break-word;} |
||
| 81 | div {position:relative; margin:auto; width:950px; border: 1px solid #a6c9e2; top: 30px; margin-bottom:10px;} |
||
| 82 | p {padding:0; margin:0;} |
||
| 83 | p.title {font-size:1.2em; background-color:#D0DCE9; padding:10px;} |
||
| 84 | p.info {padding:5px; margin-top:10px; margin-bottom:10px;} |
||
| 85 | fieldset {border:none; background-color: white;} |
||
| 86 | pre {width:910px; line-height:1.5;} |
||
| 87 | </style> |
||
| 88 | </head> |
||
| 89 | <body> |
||
| 90 | <div> |
||
| 91 | <p class="title">Niarf, une erreur s\'est produite</p> |
||
| 92 | <p class="info">'.$erreurType.' Error : <strong>'.$err_msg.'</strong> in '.$err_file.' at line '.$err_line.'</p> |
||
| 93 | <fieldset><pre>'; |
||
| 94 | foreach($backtrace as $i => $info) |
||
| 95 | { |
||
| 96 | echo '#'.$i.' '.$info['function']; |
||
| 97 | |||
| 98 | if(isset($info['args']) && count($info['args']) > 0) |
||
| 99 | { |
||
| 100 | echo '('; |
||
| 101 | |||
| 102 | foreach($info['args'] as $iArgs => $args) |
||
| 103 | { |
||
| 104 | if($iArgs > 0) {echo ', ';} |
||
| 105 | |||
| 106 | if(is_array($args) || is_object($args)) {echo gettype($args);} |
||
| 107 | elseif(is_null($args)) {echo 'null';} |
||
| 108 | else {echo htmlentities($args);} |
||
| 109 | } |
||
| 110 | |||
| 111 | echo ')'; |
||
| 112 | } |
||
| 113 | |||
| 114 | if(isset($info['file'], $info['line'])) |
||
| 115 | { |
||
| 116 | echo ' called at ['.$info['file'].' line '.$info['line'].']'; |
||
| 117 | } |
||
| 118 | echo "\n\n"; |
||
| 119 | } |
||
| 120 | echo '</pre></fieldset> |
||
| 121 | </div> |
||
| 122 | <body> |
||
| 123 | </html> |
||
| 124 | '; |
||
| 125 | |||
| 126 | ob_flush(); |
||
| 127 | exit; |
||
| 128 | } |
||
| 129 | } |
||
| 130 |