| Conditions | 13 |
| Paths | 18 |
| Total Lines | 57 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 46 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 47 | { |
||
| 48 | $io = new SymfonyStyle($input, $output); |
||
| 49 | $bundleName = $input->getArgument('bundle_name'); |
||
| 50 | $ignoreDeps = $input->getOption('ignore_deps'); |
||
| 51 | |||
| 52 | if (false !== $this->isInstalled($bundleName)) { |
||
|
|
|||
| 53 | if ($input->isInteractive()) { |
||
| 54 | $io->error('Extension is already installed but possibly inactive.'); |
||
| 55 | } |
||
| 56 | |||
| 57 | return 1; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** @var $extension ExtensionEntity */ |
||
| 61 | if (false === $extension = $this->load($bundleName)) { |
||
| 62 | if ($input->isInteractive()) { |
||
| 63 | $io->error('Extension could not be found and loaded from the expected directory'); |
||
| 64 | } |
||
| 65 | |||
| 66 | return 2; |
||
| 67 | } |
||
| 68 | |||
| 69 | if (!$ignoreDeps) { |
||
| 70 | if (false === $this->installDependencies($extension)) { |
||
| 71 | if ($input->isInteractive()) { |
||
| 72 | $io->error('Required dependencies could not be installed'); |
||
| 73 | } |
||
| 74 | |||
| 75 | return 3; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | if (false === $this->extensionHelper->install($extension)) { |
||
| 80 | if ($input->isInteractive()) { |
||
| 81 | $io->error('Could not install the extension'); |
||
| 82 | } |
||
| 83 | |||
| 84 | return 4; |
||
| 85 | } |
||
| 86 | |||
| 87 | if (0 !== $this->clearCache()) { |
||
| 88 | if ($input->isInteractive()) { |
||
| 89 | $io->error('Could not clear the cache (--no-warmup)'); |
||
| 90 | } |
||
| 91 | |||
| 92 | return 5; |
||
| 93 | } |
||
| 94 | |||
| 95 | $event = new ModuleStateEvent($this->kernel->getModule($extension->getName()), $extension->toArray()); |
||
| 96 | $this->eventDispatcher->dispatch($event, CoreEvents::MODULE_POSTINSTALL); |
||
| 97 | |||
| 98 | if ($input->isInteractive()) { |
||
| 99 | $io->success('Extension installed'); |
||
| 100 | } |
||
| 101 | |||
| 102 | return 0; |
||
| 103 | } |
||
| 144 |