| Conditions | 9 | 
| Paths | 7 | 
| Total Lines | 64 | 
| Code Lines | 33 | 
| 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  | 
            ||
| 30 | protected function execute(InputInterface $input, OutputInterface $output): int  | 
            ||
| 31 |     { | 
            ||
| 32 | parent::execute($input, $output);  | 
            ||
| 33 | |||
| 34 |         $configFilePath = PathUtils::getAbsolutePath($input->getOption('config')); | 
            ||
| 35 | $configFileDir = dirname($configFilePath);  | 
            ||
| 36 | |||
| 37 | if (!is_writable($configFileDir))  | 
            ||
| 38 |         { | 
            ||
| 39 |             $output->writeln("<error>Cannot write to {$configFileDir}</error>"); | 
            ||
| 40 | |||
| 41 | return 1;  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 | |||
| 45 | $container = $this->getContainer();  | 
            ||
| 46 | |||
| 47 |         $configuration = new Configuration($input->getOption('path') ?: $this->consoleStyle->ask('Local path', '.')); | 
            ||
| 48 |         $configuration->setIdentity($input->getOption('identity') ?: $this->consoleStyle->ask('Identity', get_current_user())); | 
            ||
| 49 |         $configuration->setExclude($input->getOption('exclude') ?: $this->consoleStyle->askMultiple('Excluded path(s)')); | 
            ||
| 50 | |||
| 51 | // at least one storage driver has to be set up  | 
            ||
| 52 | do  | 
            ||
| 53 |         { | 
            ||
| 54 |             $vaultConfig = new VaultConfiguration($this->consoleStyle->choice('Storage driver', $container->getStorageAdapterNames())); | 
            ||
| 55 |             $vaultConfig->setTitle($this->consoleStyle->ask('Title', $vaultConfig->getAdapter())); | 
            ||
| 56 |             $vaultConfig->setLockAdapter($this->consoleStyle->choice('Lock adapter', $container->getLockAdapterNames(), $vaultConfig->getLockAdapter())); | 
            ||
| 57 |             $vaultConfig->setIndexMerger($this->consoleStyle->choice('Index merger', $container->getIndexMergerNames(), $vaultConfig->getIndexMerger())); | 
            ||
| 58 |             $vaultConfig->setConflictHandler($this->consoleStyle->choice('Conflict handler', $container->getConflictHandlerNames(), $vaultConfig->getConflictHandler())); | 
            ||
| 59 |             $vaultConfig->setOperationListBuilder($this->consoleStyle->choice('Operation list builder', $container->getOperationListBuilderNames(), $vaultConfig->getOperationListBuilder())); | 
            ||
| 60 | |||
| 61 |             while ($settingName = $this->consoleStyle->ask('Additional setting name')) | 
            ||
| 62 |             { | 
            ||
| 63 |                 if ($settingValue = $this->consoleStyle->ask('Additional setting value')) | 
            ||
| 64 |                 { | 
            ||
| 65 | $vaultConfig->setSetting($settingName, $settingValue);  | 
            ||
| 66 | }  | 
            ||
| 67 | }  | 
            ||
| 68 | |||
| 69 | $configuration->addVault($vaultConfig);  | 
            ||
| 70 | }  | 
            ||
| 71 |         while($this->consoleStyle->choice('Add another vault?', ['y', 'n'], 'n') === 'y'); | 
            ||
| 72 | |||
| 73 | |||
| 74 |         $skipDefaults = !$input->getOption('writeDefaults'); | 
            ||
| 75 | |||
| 76 | $configurationFileWriter = new ConfigurationFileWriter();  | 
            ||
| 77 | |||
| 78 |         $output->writeln("The following content will be written to {$configFilePath}:"); | 
            ||
| 79 | $output->writeln($configurationFileWriter->buildConfigurationFile($configuration, $skipDefaults));  | 
            ||
| 80 | |||
| 81 |         if ($this->consoleStyle->confirm('Continue? ', true)) | 
            ||
| 82 |         { | 
            ||
| 83 | $configurationFileWriter->writeConfigurationFile($configuration, $configFilePath, $skipDefaults);  | 
            ||
| 84 | |||
| 85 |             $output->writeln("<info>Successfully written config file to {$configFilePath}</info>"); | 
            ||
| 86 | }  | 
            ||
| 87 | else  | 
            ||
| 88 |         { | 
            ||
| 89 |             $output->writeln("<comment>Aborted</comment>"); | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 | return 0;  | 
            ||
| 93 | }  | 
            ||
| 94 | }  | 
            ||
| 95 |