| Conditions | 10 |
| Paths | 13 |
| Total Lines | 41 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 25 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 26 | { |
||
| 27 | if (!is_file($input->getArgument('config'))) { |
||
| 28 | throw new InvalidArgumentException('File "' . $input->getArgument('config') . '" does not exist'); |
||
| 29 | } |
||
| 30 | parse_str($input->getOption('params'), $params); |
||
| 31 | extract($params); |
||
| 32 | |||
| 33 | $checkDictionariesConfig = require_once $input->getArgument('config'); |
||
| 34 | if ($checkDictionariesConfig instanceof InvalidConfigInstanceReturnedException) { |
||
| 35 | throw $checkDictionariesConfig; |
||
| 36 | } |
||
| 37 | if (!$checkDictionariesConfig instanceof CheckDictionariesConfig) { |
||
| 38 | throw new InvalidConfigInstanceReturnedException('"' . (is_object($checkDictionariesConfig) ? get_class($checkDictionariesConfig) : $checkDictionariesConfig) . '" is not instance of ' . CheckDictionariesConfig::class); |
||
| 39 | } |
||
| 40 | |||
| 41 | $output->writeln(''); |
||
| 42 | $output->writeln('Loading dictionaries...'); |
||
| 43 | $dictionaries = $checkDictionariesConfig->load(); |
||
| 44 | |||
| 45 | $errors = []; |
||
| 46 | foreach ($dictionaries as $lang1 => $dictionary1) { |
||
| 47 | foreach ($dictionaries as $lang2 => $dictionary2) { |
||
| 48 | if ($lang1 === $lang2) { |
||
| 49 | continue; |
||
| 50 | } |
||
| 51 | $missingTranslations = array_diff(array_keys($dictionary1), array_keys($dictionary2)); |
||
| 52 | foreach ($missingTranslations as $missingTranslation) { |
||
| 53 | $errors[] = 'Missing translation for key ' . $missingTranslation . ' for language ' . $lang2; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | $output->writeln('', OutputInterface::VERBOSITY_VERY_VERBOSE); |
||
| 59 | foreach (array_unique($errors) as $error) { |
||
| 60 | $output->writeln($error, OutputInterface::VERBOSITY_VERY_VERBOSE); |
||
| 61 | } |
||
| 62 | |||
| 63 | $output->writeln(''); |
||
| 64 | $output->writeln('<comment>' . count($errors) . ' errors found</comment>'); |
||
| 65 | return count($errors); |
||
| 66 | } |
||
| 68 |