Conditions | 14 |
Paths | 8192 |
Total Lines | 84 |
Code Lines | 48 |
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 |
||
45 | protected function execute(InputInterface $input, OutputInterface $output) |
||
46 | { |
||
47 | $subCommandFactory = $this->createSubCommandFactory( |
||
48 | $input, |
||
49 | $output, |
||
50 | 'N98\Magento\Command\Developer\Module\Create\SubCommand' // sub-command namespace |
||
51 | ); |
||
52 | |||
53 | $configBag = $subCommandFactory->getConfig(); |
||
54 | |||
55 | if (!$input->getOption('modman')) { |
||
56 | $this->detectMagento($output); |
||
57 | } |
||
58 | |||
59 | $configBag->setBool('isModmanMode', $input->getOption('modman')); |
||
60 | $configBag->setString('magentoRootFolder', $this->_magentoRootFolder); |
||
|
|||
61 | |||
62 | $this->initConfigBagDefaultValues($configBag); |
||
63 | |||
64 | if ($input->getOption('add-all')) { |
||
65 | $configBag->setBool('shouldAddBlocks', true); |
||
66 | $configBag->setBool('shouldAddHelpers', true); |
||
67 | $configBag->setBool('shouldAddModels', true); |
||
68 | $configBag->setBool('shouldAddSetup', true); |
||
69 | } |
||
70 | |||
71 | if ($input->getOption('add-blocks')) { |
||
72 | $configBag->setBool('shouldAddBlocks', true); |
||
73 | } |
||
74 | |||
75 | if ($input->getOption('add-helpers')) { |
||
76 | $configBag->setBool('shouldAddHelpers', true); |
||
77 | } |
||
78 | |||
79 | if ($input->getOption('add-models')) { |
||
80 | $configBag->setBool('shouldAddModels', true); |
||
81 | } |
||
82 | |||
83 | if ($input->getOption('add-setup')) { |
||
84 | $configBag->setBool('shouldAddSetup', true); |
||
85 | } |
||
86 | |||
87 | if ($input->getOption('enable')) { |
||
88 | $configBag->setBool('shouldEnableModule', true); |
||
89 | } |
||
90 | |||
91 | $configBag->setString('baseFolder', __DIR__ . '/../../../../../../res/module/create'); |
||
92 | $configBag->setString('vendorNamespace', ucfirst($input->getArgument('vendorNamespace'))); |
||
93 | $configBag->setString('moduleName', ucfirst($input->getArgument('moduleName'))); |
||
94 | |||
95 | $this->initView($input, $configBag); |
||
96 | |||
97 | $subCommandFactory->create('CreateModuleFolders')->execute(); |
||
98 | $subCommandFactory->create('CreateModuleRegistrationFiles')->execute(); |
||
99 | |||
100 | if (!$input->getOption('minimal')) { |
||
101 | $subCommandFactory->create('CreateModuleConfigFile')->execute(); |
||
102 | $subCommandFactory->create('CreateModuleDiFile')->execute(); |
||
103 | $subCommandFactory->create('CreateModuleEventsFile')->execute(); |
||
104 | $subCommandFactory->create('CreateModuleCrontabFile')->execute(); |
||
105 | } |
||
106 | |||
107 | $subCommandFactory->create('EnableModule')->execute(); |
||
108 | |||
109 | if ($input->getOption('add-readme')) { |
||
110 | $subCommandFactory->create('CreateReadmeFile')->execute(); |
||
111 | } |
||
112 | |||
113 | if ($input->getOption('modman')) { |
||
114 | $subCommandFactory->create('CreateModmanFile')->execute(); |
||
115 | } |
||
116 | |||
117 | if ($input->getOption('add-composer')) { |
||
118 | $subCommandFactory->create('CreateComposerFile')->execute(); |
||
119 | } |
||
120 | |||
121 | if ($input->getOption('add-setup')) { |
||
122 | $subCommandFactory->create('CreateSetupFiles')->execute(); |
||
123 | } |
||
124 | |||
125 | if (!$input->getOption('minimal')) { |
||
126 | $subCommandFactory->create('CreateAdditionalFiles')->execute(); |
||
127 | } |
||
128 | } |
||
129 | |||
157 |
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: