Conditions | 10 |
Paths | 5 |
Total Lines | 67 |
Code Lines | 30 |
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 |
||
51 | public static function defaultErrorRender( |
||
52 | $errType, |
||
53 | $errMsg, |
||
54 | $errFile, |
||
55 | $errLine, |
||
56 | $backtrace |
||
57 | ) { |
||
58 | http_response_code(500); |
||
59 | ob_clean(); |
||
60 | |||
61 | echo ' |
||
62 | <!doctype html> |
||
63 | <html lang="fr"> |
||
64 | <head> |
||
65 | <title>An error is detected !</title> |
||
66 | <style> |
||
67 | html {padding:0; margin:0; background-color:#e3e3e3; font-family:sans-serif; font-size: 1em; word-wrap:break-word;} |
||
68 | div {position:relative; margin:auto; width:950px; border: 1px solid #a6c9e2; top: 30px; margin-bottom:10px;} |
||
69 | p {padding:0; margin:0;} |
||
70 | p.title {font-size:1.2em; background-color:#D0DCE9; padding:10px;} |
||
71 | p.info {padding:5px; margin-top:10px; margin-bottom:10px;} |
||
72 | fieldset {border:none; background-color: white;} |
||
73 | pre {width:910px; line-height:1.5;} |
||
74 | </style> |
||
75 | </head> |
||
76 | <body> |
||
77 | <div> |
||
78 | <p class="title">Niarf, an error is detected !</p> |
||
79 | <p class="info">'.$errType.' Error : <strong>'.$errMsg.'</strong> in '.$errFile.' at line '.$errLine.'</p> |
||
80 | <fieldset><pre>'; |
||
81 | foreach ($backtrace as $i => $info) { |
||
82 | echo '#'.$i.' '.$info['function']; |
||
83 | |||
84 | if (isset($info['args']) && count($info['args']) > 0) { |
||
85 | echo '('; |
||
86 | |||
87 | foreach ($info['args'] as $iArgs => $args) { |
||
88 | if ($iArgs > 0) { |
||
89 | echo ', '; |
||
90 | } |
||
91 | |||
92 | if (is_array($args) || is_object($args)) { |
||
93 | echo gettype($args); |
||
94 | } elseif (is_null($args)) { |
||
95 | echo 'null'; |
||
96 | } else { |
||
97 | echo htmlentities($args); |
||
98 | } |
||
99 | } |
||
100 | |||
101 | echo ')'; |
||
102 | } |
||
103 | |||
104 | if (isset($info['file'], $info['line'])) { |
||
105 | echo ' called at ['.$info['file'].' line '.$info['line'].']'; |
||
106 | } |
||
107 | echo "\n\n"; |
||
108 | } |
||
109 | echo '</pre></fieldset> |
||
110 | </div> |
||
111 | <body> |
||
112 | </html> |
||
113 | '; |
||
114 | |||
115 | ob_flush(); |
||
116 | exit; |
||
117 | } |
||
118 | } |
||
119 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.