| Conditions | 4 |
| Paths | 8 |
| Total Lines | 57 |
| Code Lines | 25 |
| Lines | 18 |
| Ratio | 31.58 % |
| Changes | 4 | ||
| Bugs | 0 | 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 namespace Comodojo\Installer; |
||
| 136 | private function packageUpdate($initial, $target) { |
||
| 137 | |||
| 138 | $initial_actions_map = Parser::parse($initial); |
||
| 139 | |||
| 140 | $target_actions_map = Parser::parse($target); |
||
| 141 | |||
| 142 | $initial_package_name = $initial->getPrettyName(); |
||
| 143 | |||
| 144 | $target_package_name = $target->getPrettyName(); |
||
| 145 | |||
| 146 | $initial_package_path = $this->composer->getInstallationManager()->getInstallPath($initial); |
||
| 147 | |||
| 148 | $target_package_path = $this->composer->getInstallationManager()->getInstallPath($target); |
||
| 149 | |||
| 150 | $initial_actions = array_keys($initial_actions_map); |
||
| 151 | |||
| 152 | $target_actions = array_keys($target_actions_map); |
||
| 153 | |||
| 154 | $uninstall = array_diff($initial_actions, $target_actions); |
||
| 155 | |||
| 156 | $install = array_diff($target_actions, $initial_actions); |
||
| 157 | |||
| 158 | $update = array_intersect($initial_actions, $target_actions); |
||
| 159 | |||
| 160 | $installer = $this->getPackageInstaller(); |
||
| 161 | |||
| 162 | foreach ($uninstall as $action_uninstall) { |
||
| 163 | |||
| 164 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_uninstall; |
||
| 165 | |||
| 166 | $action = new $action_fqcn($this->composer, $this->io, $initial_package_path, $installer); |
||
| 167 | |||
| 168 | $action->uninstall($initial_package_name, $initial_actions_map[$action_uninstall]); |
||
| 169 | |||
| 170 | } |
||
| 171 | |||
| 172 | View Code Duplication | foreach ($install as $action_install) { |
|
| 173 | |||
| 174 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_install; |
||
| 175 | |||
| 176 | $action = new $action_fqcn($this->composer, $this->io, $target_package_path, $installer); |
||
| 177 | |||
| 178 | $action->install($target_package_name, $target_actions_map[$action_install]); |
||
| 179 | |||
| 180 | } |
||
| 181 | |||
| 182 | View Code Duplication | foreach ($update as $action_update) { |
|
| 183 | |||
| 184 | $action_fqcn = 'Comodojo\\Installer\\Actions\\' . $action_update; |
||
| 185 | |||
| 186 | $action = new $action_fqcn($this->composer, $this->io, $target_package_path, $installer); |
||
| 187 | |||
| 188 | $action->update($target_package_name, $initial_actions_map[$action_update], $target_actions_map[$action_update]); |
||
| 189 | |||
| 190 | } |
||
| 191 | |||
| 192 | } |
||
| 193 | |||
| 201 |
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: