Conditions | 9 |
Paths | 34 |
Total Lines | 59 |
Code Lines | 34 |
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 | return 0; |
||
64 | } |
||
65 | |||
66 | $failedCount = 0; |
||
67 | /** @var TestCase $suite */ |
||
68 | foreach ($testCollection as $suite) { |
||
69 | if ($suite instanceof WarningTestCase) { |
||
70 | continue; |
||
71 | } |
||
72 | |||
73 | $testClass = get_class($suite); |
||
74 | $testMethod = $suite->getName(false); |
||
75 | $testSignature = $testClass . '::' . $suite->getName(); |
||
76 | |||
77 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) { |
||
78 | $this->writeValidity($output, 'Validating ' . $testSignature . '...'); |
||
79 | } |
||
80 | |||
81 | $isValid = Validator::isValidMethod( |
||
82 | $testClass, |
||
83 | $testMethod |
||
84 | ); |
||
85 | |||
86 | if (!$isValid) { |
||
87 | $failedCount++; |
||
88 | $this->writeValidity($output, $testSignature, false); |
||
89 | } elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
||
90 | $this->writeValidity($output, $testSignature, true); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | $output->writeln(''); |
||
95 | |||
96 | if ($failedCount > 0) { |
||
97 | $output->writeln( |
||
98 | "There were {$failedCount} test(s) with invalid @covers tags." |
||
99 | ); |
||
100 | |||
101 | return 1; |
||
102 | } |
||
103 | |||
104 | $output->writeln('Validation complete. All @covers tags are valid.'); |
||
105 | |||
106 | return 0; |
||
107 | } |
||
135 |