Conditions | 12 |
Paths | 16 |
Total Lines | 24 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 156 |
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 |
||
26 | function getallheaders(): array |
||
27 | { |
||
28 | 2 | $headers = []; |
|
29 | 2 | foreach ($_SERVER as $h => $v) { |
|
30 | 2 | if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
31 | $headers[$hp[1]] = $v; |
||
32 | } |
||
33 | } |
||
34 | 2 | return $headers; |
|
35 | } |
||
36 | } |
||
37 | |||
38 | if (file_exists(CORE_DIR)) { |
||
39 | $loaded_files = []; |
||
40 | //Autoload de módulos |
||
41 | $finder = new Finder(); |
||
42 | $finder->files()->in(CORE_DIR)->name('autoload.php'); |
||
43 | /* @var $file SplFileInfo */ |
||
44 | foreach ($finder as $file) { |
||
45 | $path = $file->getRealPath(); |
||
46 | if (!in_array($path, $loaded_files)) { |
||
47 | $loaded_files[] = $path; |
||
48 | require_once($path); |
||
49 | } |
||
50 | } |
||
59 |