Conditions | 9 |
Paths | 34 |
Total Lines | 60 |
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 | |||
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 | $testMethod = $suite->getName(false); |
||
76 | $testSignature = $testClass.'::'.$suite->getName(); |
||
77 | |||
78 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) { |
||
79 | $this->writeValidity($output, 'Validating '.$testSignature.'...'); |
||
80 | } |
||
81 | |||
82 | $isValid = Validator::isValidMethod( |
||
83 | $testClass, |
||
84 | $testMethod |
||
85 | ); |
||
86 | |||
87 | if (!$isValid) { |
||
88 | ++$failedCount; |
||
89 | $this->writeValidity($output, $testSignature, false); |
||
90 | } elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
||
91 | $this->writeValidity($output, $testSignature, true); |
||
92 | } |
||
93 | } |
||
94 | |||
95 | $output->writeln(''); |
||
96 | |||
97 | if ($failedCount > 0) { |
||
98 | $output->writeln( |
||
99 | "There were {$failedCount} test(s) with invalid @covers tags." |
||
100 | ); |
||
101 | |||
102 | return 1; |
||
103 | } |
||
104 | |||
105 | $output->writeln('Validation complete. All @covers tags are valid.'); |
||
106 | |||
107 | return 0; |
||
108 | } |
||
137 |