| Conditions | 7 |
| Paths | 12 |
| Total Lines | 56 |
| Code Lines | 39 |
| 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 |
||
| 51 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 52 | { |
||
| 53 | $formatter = $this->getHelper('formatter'); |
||
| 54 | $infoStyle = new OutputFormatterStyle('white', 'blue'); |
||
| 55 | $output->getFormatter()->setStyle('info', $infoStyle); |
||
| 56 | $formattedInfoBlock = $formatter->formatBlock(['INFO:', 'Check existing addresses in the database'], 'info', TRUE); |
||
| 57 | |||
| 58 | $output->writeln(''); |
||
| 59 | $output->writeln($formattedInfoBlock); |
||
| 60 | $output->writeln(''); |
||
| 61 | |||
| 62 | |||
| 63 | $successStyle = new OutputFormatterStyle('white', 'green'); |
||
| 64 | $output->getFormatter()->setStyle('success', $successStyle); |
||
| 65 | |||
| 66 | // Get all addresses |
||
| 67 | $collection = $this->quoteAddressCollectionFactory->create(); |
||
| 68 | $collection->addFieldToSelect('*'); |
||
| 69 | $collection->setPageSize(50); |
||
| 70 | $pages = $collection->getLastPageNumber(); |
||
| 71 | $foundAddresses = []; |
||
| 72 | $found = 0; |
||
| 73 | |||
| 74 | for ($pageNum = 1; $pageNum <= $pages; $pageNum++) { |
||
| 75 | $collection->setCurPage($pageNum); |
||
| 76 | foreach ($collection as $item) { |
||
| 77 | foreach ($this->addressValidation->getValidations() as $validation) { |
||
| 78 | try { |
||
| 79 | $validation->execute($item); |
||
| 80 | } catch (\Exception $e) { |
||
| 81 | $foundAddresses[$item->getId()] = 1; |
||
| 82 | $found++; |
||
| 83 | $addressType = $item->getAddressType() ? '<success>' . $item->getAddressType() . '</success>' : '<error>EMPTY</error>'; |
||
| 84 | $output->writeln('Address type: ' . $addressType . '</info>; ID: <success>' . $item->getId() . '</success>; Message: <fg=#c0392b;bg=black>' . $e->getMessage() . '</>'); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | $collection->clear(); |
||
| 90 | } |
||
| 91 | |||
| 92 | $output->writeln(''); |
||
| 93 | |||
| 94 | if ($found === 0) { |
||
| 95 | $infoStyle = new OutputFormatterStyle('white', 'green'); |
||
| 96 | $output->getFormatter()->setStyle('info', $infoStyle); |
||
| 97 | $formattedInfoBlock = $formatter->formatBlock(['RESULT:', 'All addresses are valid'], 'info', TRUE); |
||
| 98 | $output->writeln($formattedInfoBlock); |
||
| 99 | } else { |
||
| 100 | $infoStyle = new OutputFormatterStyle('white', 'red'); |
||
| 101 | $output->getFormatter()->setStyle('info', $infoStyle); |
||
| 102 | $formattedInfoBlock = $formatter->formatBlock(['RESULT:', 'We found ' . array_sum($foundAddresses) . ' addresses with issues and ' . $found . ' fields which do not pass validation. Please update validation regex.'], 'info', TRUE); |
||
| 103 | $output->writeln($formattedInfoBlock); |
||
| 104 | } |
||
| 105 | |||
| 106 | return 0; |
||
| 107 | } |
||
| 109 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths