| Conditions | 8 |
| Paths | 6 |
| Total Lines | 56 |
| Code Lines | 23 |
| 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 |
||
| 31 | public function run() |
||
| 32 | { |
||
| 33 | $this->isloaded = true; |
||
| 34 | |||
| 35 | $content = null; |
||
| 36 | |||
| 37 | $path = glob($this->filepath); |
||
| 38 | |||
| 39 | if (!$path) { |
||
| 40 | $this->isloaded = false; |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | |||
| 44 | foreach ($path as $filemain) |
||
| 45 | { |
||
| 46 | $fileInfo = pathinfo($filemain); |
||
| 47 | |||
| 48 | $pathInfo = $fileInfo['dirname'].DIRECTORY_SEPARATOR.$fileInfo['basename']; |
||
| 49 | |||
| 50 | if (is_dir($pathInfo)) { |
||
| 51 | $dirlist = @scandir($pathInfo); |
||
| 52 | |||
| 53 | foreach ($dirlist as $file) { |
||
| 54 | |||
| 55 | $fileInfoFolder = pathinfo($file); |
||
| 56 | |||
| 57 | $pathInfoFolder = $fileInfoFolder['dirname'].DIRECTORY_SEPARATOR.$fileInfoFolder['basename']; |
||
| 58 | |||
| 59 | if ($this->isReadable($path)) { |
||
| 60 | |||
| 61 | if (in_array($fileInfoFolder['extension'], $this->extension)) { |
||
| 62 | |||
| 63 | $content .= file_get_contents($pathInfoFolder); |
||
| 64 | |||
| 65 | } else { |
||
| 66 | |||
| 67 | throw new Exception('Invalid extension'); |
||
| 68 | |||
| 69 | } |
||
| 70 | |||
| 71 | } |
||
| 72 | |||
| 73 | } |
||
| 74 | |||
| 75 | } else { |
||
| 76 | |||
| 77 | if (is_readable($pathInfo)) { |
||
| 78 | |||
| 79 | $content .= file_get_contents($pathInfo); |
||
| 80 | } |
||
| 81 | |||
| 82 | } |
||
| 83 | |||
| 84 | } |
||
| 85 | |||
| 86 | return $content; |
||
| 87 | } |
||
| 98 |