Conditions | 5 |
Paths | 6 |
Total Lines | 115 |
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 |
||
126 | public function autoindex($path, $dir) |
||
127 | { |
||
128 | |||
129 | $this->onWakeup(); |
||
130 | ?> |
||
131 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
||
132 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
||
133 | <head> |
||
134 | <title>Index of /</title> |
||
135 | <style type="text/css"> |
||
136 | a, a:active { |
||
137 | text-decoration: none; |
||
138 | color: blue; |
||
139 | } |
||
140 | |||
141 | a:visited { |
||
142 | color: #48468F; |
||
143 | } |
||
144 | |||
145 | a:hover, a:focus { |
||
146 | text-decoration: underline; |
||
147 | color: red; |
||
148 | } |
||
149 | |||
150 | body { |
||
151 | background-color: #F5F5F5; |
||
152 | } |
||
153 | |||
154 | h2 { |
||
155 | margin-bottom: 12px; |
||
156 | } |
||
157 | |||
158 | table { |
||
159 | margin-left: 12px; |
||
160 | } |
||
161 | |||
162 | th, td { |
||
163 | font: 90% monospace; |
||
164 | text-align: left; |
||
165 | } |
||
166 | |||
167 | th { |
||
168 | font-weight: bold; |
||
169 | padding-right: 14px; |
||
170 | padding-bottom: 3px; |
||
171 | } |
||
172 | |||
173 | td { |
||
174 | padding-right: 14px; |
||
175 | } |
||
176 | |||
177 | td.s, th.s { |
||
178 | text-align: right; |
||
179 | } |
||
180 | |||
181 | div.list { |
||
182 | background-color: white; |
||
183 | border-top: 1px solid #646464; |
||
184 | border-bottom: 1px solid #646464; |
||
185 | padding-top: 10px; |
||
186 | padding-bottom: 14px; |
||
187 | } |
||
188 | |||
189 | div.foot { |
||
190 | font: 90% monospace; |
||
191 | color: #787878; |
||
192 | padding-top: 4px; |
||
193 | } |
||
194 | </style> |
||
195 | </head> |
||
196 | <body> |
||
197 | <pre class="header">Welcome!</pre> |
||
198 | <h2>Index of /</h2> |
||
199 | |||
200 | <div class="list"> |
||
201 | <table summary="Directory Listing" cellpadding="0" cellspacing="0"> |
||
202 | <thead> |
||
203 | <tr> |
||
204 | <th class="n">Name</th> |
||
205 | <th class="t">Type</th> |
||
206 | </tr> |
||
207 | </thead> |
||
208 | <tbody> |
||
209 | <tr> |
||
210 | <td class="n"><a href="../../">Parent Directory</a>/</td> |
||
211 | <td class="t">Directory</td> |
||
212 | |||
213 | </tr> |
||
214 | <?php |
||
215 | foreach ($dir['dents'] as $item) { |
||
216 | $type = $item['type'] === EIO_DT_DIR ? 'Directory' : \PHPDaemon\Utils\MIME::get($path . $item['name']); |
||
217 | ?> |
||
218 | <tr> |
||
219 | <td class="n"><a |
||
220 | href="<?php echo htmlspecialchars($item['name']) . ($type == 'Directory' ? '/' : ''); |
||
221 | ?>"><?php echo htmlspecialchars($item['name']); |
||
222 | ?></a></td> |
||
223 | <td class="t"><?php echo $type; |
||
224 | ?></td> |
||
225 | </tr> |
||
226 | <?php |
||
227 | } |
||
228 | ?> |
||
229 | </tbody> |
||
230 | </table> |
||
231 | </div> |
||
232 | <?php if ($this->upstream->pool->config->expose->value) : ?> |
||
233 | <div class="foot"> |
||
234 | phpDaemon/<?php echo \PHPDaemon\Core\Daemon::$version; ?> |
||
235 | </div> |
||
236 | <?php endif; ?> |
||
237 | </body> |
||
238 | </html> |
||
239 | <?php |
||
240 | } |
||
241 | |||
258 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.