| Conditions | 5 |
| Paths | 5 |
| Total Lines | 52 |
| 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 |
||
| 50 | public static function readFolderPackages($item, $realPath) |
||
| 51 | { |
||
| 52 | if (in_array($item, ['.', '..'])) { |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | |||
| 56 | if (is_file($realPath . $item)) { |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | |||
| 60 | if (!is_dir($realPath . $item)) { |
||
| 61 | return ; |
||
| 62 | } |
||
| 63 | $filesystem = app(Filesystem::class); |
||
| 64 | |||
| 65 | if ($filesystem->exists($realPath . $item.'/composer.lock')) { |
||
| 66 | // Get the composer.lock file |
||
| 67 | $composer = json_decode( |
||
| 68 | $filesystem->get($realPath . $item.'/composer.json') |
||
| 69 | ); |
||
| 70 | $composerLock = json_decode( |
||
| 71 | $filesystem->get($realPath . $item.'/composer.lock') |
||
| 72 | ); |
||
| 73 | |||
| 74 | $project = new Project(); |
||
| 75 | $project->setName($composer->name); |
||
| 76 | $project->setSlug($composer->name); |
||
| 77 | |||
| 78 | $project->save(); |
||
| 79 | |||
| 80 | $event = new ProjectEvent($project); |
||
| 81 | event($event); // @todo FabricaEvents::PROJECT_CREATE fabrica_core.event_dispatcher |
||
| 82 | |||
| 83 | // //@todo |
||
| 84 | // unset($composerLock->packages); |
||
| 85 | // dd('Fabrica', |
||
| 86 | // // $composerLock, |
||
| 87 | // $composer, |
||
| 88 | // $realPath . $item |
||
| 89 | // ); |
||
| 90 | |||
| 91 | // // // Loop through all the packages and get the version of transmissor |
||
| 92 | // // foreach ($composerLock->packages as $package) { |
||
| 93 | // // if ($package->name == $this->packageName) { |
||
| 94 | // // $this->version = $package->version; |
||
| 95 | // // break; |
||
| 96 | // // } |
||
| 97 | // // } |
||
| 98 | } |
||
| 99 | |||
| 100 | return ; |
||
| 101 | } |
||
| 102 | } |
||
| 103 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.