| Conditions | 12 | 
| Paths | 183 | 
| Total Lines | 76 | 
| Code Lines | 47 | 
| 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  | 
            ||
| 73 | protected function executeCommand(IO $io): int  | 
            ||
| 74 |     { | 
            ||
| 75 | $input = $io->getInput();  | 
            ||
| 76 | |||
| 77 |         try { | 
            ||
| 78 | $config = ConfigurationLoader::getConfig(  | 
            ||
| 79 | $input->getArgument(self::FILE_ARGUMENT) ?? $this->getConfigurationHelper()->findDefaultPath(),  | 
            ||
| 80 | $this->getConfigurationHelper(),  | 
            ||
| 81 | $io,  | 
            ||
| 82 | false  | 
            ||
| 83 | );  | 
            ||
| 84 | |||
| 85 | $recommendations = $config->getRecommendations();  | 
            ||
| 86 | $warnings = $config->getWarnings();  | 
            ||
| 87 | |||
| 88 | MessageRenderer::render($io, $recommendations, $warnings);  | 
            ||
| 89 | |||
| 90 | $hasRecommendationsOrWarnings = [] === $recommendations && [] === $warnings;  | 
            ||
| 91 | |||
| 92 |             if (false === $hasRecommendationsOrWarnings) { | 
            ||
| 93 |                 if ([] === $recommendations) { | 
            ||
| 94 |                     $io->caution('The configuration file passed the validation with warnings.'); | 
            ||
| 95 |                 } elseif ([] === $warnings) { | 
            ||
| 96 |                     $io->caution('The configuration file passed the validation with recommendations.'); | 
            ||
| 97 |                 } else { | 
            ||
| 98 |                     $io->caution('The configuration file passed the validation with recommendations and warnings.'); | 
            ||
| 99 | }  | 
            ||
| 100 |             } else { | 
            ||
| 101 |                 $io->success('The configuration file passed the validation.'); | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 104 | return $hasRecommendationsOrWarnings || $input->getOption(self::IGNORE_MESSAGES_OPTION) ? 0 : 1;  | 
            ||
| 105 |         } catch (Exception $exception) { | 
            ||
| 106 | // Continue  | 
            ||
| 107 | }  | 
            ||
| 108 | |||
| 109 |         if ($io->isVerbose()) { | 
            ||
| 110 | throw new RuntimeException(  | 
            ||
| 111 | sprintf(  | 
            ||
| 112 | 'The configuration file failed validation: %s',  | 
            ||
| 113 | $exception->getMessage()  | 
            ||
| 114 | ),  | 
            ||
| 115 | $exception->getCode(),  | 
            ||
| 116 | $exception  | 
            ||
| 117 | );  | 
            ||
| 118 | }  | 
            ||
| 119 | |||
| 120 |         if ($exception instanceof JsonValidationException) { | 
            ||
| 121 | $io->writeln(  | 
            ||
| 122 | sprintf(  | 
            ||
| 123 | '<error>The configuration file failed validation: "%s" does not match the expected JSON '  | 
            ||
| 124 | .'schema:</error>',  | 
            ||
| 125 | $exception->getValidatedFile()  | 
            ||
| 126 | )  | 
            ||
| 127 | );  | 
            ||
| 128 | |||
| 129 |             $io->writeln(''); | 
            ||
| 130 | |||
| 131 |             foreach ($exception->getErrors() as $error) { | 
            ||
| 132 |                 $io->writeln("<comment>  - $error</comment>"); | 
            ||
| 133 | }  | 
            ||
| 134 |         } else { | 
            ||
| 135 | $errorMessage = isset($exception)  | 
            ||
| 136 |                 ? sprintf('The configuration file failed validation: %s', $exception->getMessage()) | 
            ||
| 137 | : 'The configuration file failed validation.'  | 
            ||
| 138 | ;  | 
            ||
| 139 | |||
| 140 | $io->writeln(  | 
            ||
| 141 | sprintf(  | 
            ||
| 142 | '<error>%s</error>',  | 
            ||
| 143 | $errorMessage  | 
            ||
| 144 | )  | 
            ||
| 145 | );  | 
            ||
| 146 | }  | 
            ||
| 147 | |||
| 148 | return 1;  | 
            ||
| 149 | }  | 
            ||
| 151 |