| Conditions | 13 |
| Paths | 60 |
| Total Lines | 41 |
| 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 |
||
| 110 | protected function copyDirectory($sourceDirectory, $destinationDirectory) |
||
| 111 | { |
||
| 112 | if (!is_dir($destinationDirectory)) { |
||
| 113 | mkdir($destinationDirectory); |
||
| 114 | } |
||
| 115 | |||
| 116 | $finder = new Finder(); |
||
| 117 | $finder->in($sourceDirectory); |
||
| 118 | if (!$this->copyNonPhpFiles) { |
||
| 119 | foreach ($this->extensions as $extension) { |
||
| 120 | $finder->name('*.'.$extension); |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 124 | if ($this->excludes) { |
||
| 125 | foreach ($this->excludes as $exclude) { |
||
| 126 | $finder->notPath('/^'.preg_quote($exclude, '/').'/'); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | |||
| 130 | foreach ($finder as $item) { |
||
| 131 | $target = $destinationDirectory.'/'.$item->getRelativePathname(); |
||
| 132 | |||
| 133 | if ($item->isFile()) { |
||
| 134 | $isPhpFile = $this->isPhpFile($target); |
||
| 135 | if ($isPhpFile || $this->copyNonPhpFiles) { |
||
| 136 | $targetDir = dirname($target); |
||
| 137 | if ($targetDir && !is_dir($targetDir)) { |
||
| 138 | mkdir($targetDir, 0755, true); |
||
| 139 | } |
||
| 140 | copy($item->getRealPath(), $target); |
||
| 141 | |||
| 142 | $this->log($item->getRelativePath(), $target); |
||
| 143 | |||
| 144 | if ($isPhpFile) { |
||
| 145 | $this->convertToPhp5($target); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | } |
||
| 149 | } |
||
| 150 | } |
||
| 151 | |||
| 186 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.