| Conditions | 11 |
| Paths | 82 |
| Total Lines | 68 |
| 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 |
||
| 48 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 49 | { |
||
| 50 | $output->writeln($this->getApplication()->getLongVersion()); |
||
| 51 | |||
| 52 | $configurationHolder = InputHandler::handleInput($input); |
||
| 53 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) { |
||
| 54 | $output->writeln(PHP_EOL.sprintf( |
||
| 55 | 'Configuration file loaded: %s', |
||
| 56 | $configurationHolder->getFilename() |
||
| 57 | )); |
||
| 58 | } |
||
| 59 | |||
| 60 | $testCollection = TestSuiteLoader::loadSuite($configurationHolder); |
||
| 61 | if ($testCollection->isEmpty()) { |
||
| 62 | $output->writeln(PHP_EOL.'No tests found to validate.'); |
||
| 63 | |||
| 64 | return 0; |
||
| 65 | } |
||
| 66 | |||
| 67 | $failedCount = 0; |
||
| 68 | /** @var TestCase $suite */ |
||
| 69 | foreach ($testCollection as $suite) { |
||
| 70 | if ($suite instanceof WarningTestCase) { |
||
| 71 | continue; |
||
| 72 | } |
||
| 73 | |||
| 74 | $testClass = get_class($suite); |
||
| 75 | if (method_exists($suite, 'getName')) { |
||
| 76 | // PHPUnit < 10 |
||
| 77 | $testMethod = $suite->getName(false); |
||
| 78 | } elseif (method_exists($suite, 'name')) { |
||
| 79 | // PHPUnit >= 10.0 |
||
| 80 | $testMethod = $suite->name(); |
||
| 81 | } else { |
||
| 82 | $testMethod = $suite->toString(); |
||
| 83 | } |
||
| 84 | $testSignature = $testClass.'::'.$testMethod; |
||
| 85 | |||
| 86 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) { |
||
| 87 | $this->writeValidity($output, 'Validating '.$testSignature.'...'); |
||
| 88 | } |
||
| 89 | |||
| 90 | $isValid = Validator::isValidMethod( |
||
| 91 | $testClass, |
||
| 92 | $testMethod |
||
| 93 | ); |
||
| 94 | |||
| 95 | if (!$isValid) { |
||
| 96 | ++$failedCount; |
||
| 97 | $this->writeValidity($output, $testSignature, false); |
||
| 98 | } elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
||
| 99 | $this->writeValidity($output, $testSignature, true); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | $output->writeln(''); |
||
| 104 | |||
| 105 | if ($failedCount > 0) { |
||
| 106 | $output->writeln( |
||
| 107 | "There were {$failedCount} test(s) with invalid @covers tags." |
||
| 108 | ); |
||
| 109 | |||
| 110 | return 1; |
||
| 111 | } |
||
| 112 | |||
| 113 | $output->writeln('Validation complete. All @covers tags are valid.'); |
||
| 114 | |||
| 115 | return 0; |
||
| 116 | } |
||
| 145 |