| Conditions | 8 |
| Paths | 35 |
| Total Lines | 58 |
| Code Lines | 34 |
| Lines | 12 |
| Ratio | 20.69 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 12 | public function execute() |
||
| 13 | { |
||
| 14 | $config = $this->config; |
||
| 15 | |||
| 16 | if ($config->getBool('isModmanMode')) { |
||
| 17 | $modManDir = sprintf('%s_%s/src', $config->getString('vendorNamespace'), $config->getString('moduleName')); |
||
| 18 | if (file_exists($modManDir)) { |
||
| 19 | throw new \RuntimeException('Module already exists. Stop.'); |
||
| 20 | } |
||
| 21 | mkdir($modManDir, 0777, true); |
||
| 22 | $config->setString('magentoRootFolder', './' . $modManDir); |
||
|
|
|||
| 23 | $config->setString('modmanRootFolder', './' . substr($modManDir, 0, -4)); |
||
| 24 | } |
||
| 25 | |||
| 26 | $moduleDir = $config->getString('magentoRootFolder') |
||
| 27 | . '/app/code' |
||
| 28 | . '/' . $config->getString('vendorNamespace') |
||
| 29 | . '/' . $config->getString('moduleName'); |
||
| 30 | if (file_exists($moduleDir)) { |
||
| 31 | throw new \RuntimeException('Module already exists. Stop.'); |
||
| 32 | } |
||
| 33 | |||
| 34 | $config->setString('moduleDirectory', $moduleDir); |
||
| 35 | |||
| 36 | mkdir($moduleDir, 0777, true); |
||
| 37 | $this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '<comment></info>'); |
||
| 38 | |||
| 39 | // Add etc folder |
||
| 40 | mkdir($moduleDir . '/etc'); |
||
| 41 | $this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/etc<comment></info>'); |
||
| 42 | |||
| 43 | // Add blocks folder |
||
| 44 | View Code Duplication | if ($config->getBool('shouldAddBlocks')) { |
|
| 45 | mkdir($moduleDir . '/Block'); |
||
| 46 | $this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/Block' . '<comment></info>'); |
||
| 47 | } |
||
| 48 | |||
| 49 | // Add helpers folder |
||
| 50 | View Code Duplication | if ($config->getBool('shouldAddHelpers')) { |
|
| 51 | mkdir($moduleDir . '/Helper'); |
||
| 52 | $this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/Helper' . '<comment></info>'); |
||
| 53 | } |
||
| 54 | |||
| 55 | // Add models folder |
||
| 56 | View Code Duplication | if ($config->getBool('shouldAddModels')) { |
|
| 57 | mkdir($moduleDir . '/Model'); |
||
| 58 | $this->output->writeln('<info>Created directory: <comment>' . $moduleDir . '/Model' . '<comment></info>'); |
||
| 59 | } |
||
| 60 | |||
| 61 | // Create SQL and Data folder |
||
| 62 | if ($config->getBool('shouldAddSetup')) { |
||
| 63 | $setupFolder = $moduleDir . '/Setup/'; |
||
| 64 | mkdir($setupFolder, 0777, true); |
||
| 65 | $this->output->writeln('<info>Created directory: <comment>' . $setupFolder . '<comment></info>'); |
||
| 66 | } |
||
| 67 | |||
| 68 | return true; |
||
| 69 | } |
||
| 70 | } |
||
| 71 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: