Conditions | 14 |
Paths | 1152 |
Total Lines | 60 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
105 | public function execute(InputInterface $input, OutputInterface $output): int |
||
106 | { |
||
107 | $this->options = $input->getOptions(); |
||
|
|||
108 | $this->output = $output; |
||
109 | |||
110 | // load config |
||
111 | $config = $this->getGlobalConfig(); |
||
112 | |||
113 | if (!$this->options['silent']) { |
||
114 | $output->writeln( |
||
115 | Codecept::versionString() . "\nPowered by " . Version::getVersionString(), |
||
116 | ); |
||
117 | $output->writeln( |
||
118 | 'Running with seed: ' . $this->options['seed'] . "\n", |
||
119 | ); |
||
120 | } |
||
121 | if ($this->options['group']) { |
||
122 | $output->writeln(sprintf('[Groups] <info>%s</info> ', implode(', ', $this->options['group']))); |
||
123 | } |
||
124 | if ($this->options['debug']) { |
||
125 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
||
126 | } |
||
127 | |||
128 | $userOptions = array_intersect_key($this->options, array_flip($this->passedOptionKeys($input))); |
||
129 | $userOptions['verbosity'] = $output->getVerbosity(); |
||
130 | $userOptions['seed'] = (int)$this->options['seed'] ?: mt_rand(); |
||
131 | $userOptions['colors'] = $this->options['no-colors'] || ($input->hasOption('no-ansi') && $input->getOption('no-ansi')) ? false : $config['settings']['colors']; |
||
132 | |||
133 | if ($this->options['group'] !== []) { |
||
134 | $userOptions['groups'] = $this->options['group']; |
||
135 | } |
||
136 | |||
137 | if ($this->options['skip-group'] !== []) { |
||
138 | $userOptions['excludeGroups'] = $this->options['skip-group']; |
||
139 | } |
||
140 | |||
141 | $this->codecept = new FixturesRunner($userOptions); |
||
142 | |||
143 | $suites = Configuration::suites(); |
||
144 | $this->executed = $this->runSuites($suites); |
||
145 | |||
146 | if (!empty($config['include'])) { |
||
147 | $current_dir = Configuration::projectDir(); |
||
148 | $suites += $config['include']; |
||
149 | $this->runIncludedSuites($config['include'], $current_dir); |
||
150 | } |
||
151 | |||
152 | if ($this->executed === 0) { |
||
153 | throw new TestRuntimeException( |
||
154 | sprintf("Suite '%s' could not be found", implode(', ', $suites)), |
||
155 | ); |
||
156 | } |
||
157 | |||
158 | $this->codecept->printResult(); |
||
159 | |||
160 | if (!$input->getOption('no-exit') && !$this->codecept->getResultAggregator()->wasSuccessful()) { |
||
161 | exit(1); |
||
162 | } |
||
163 | |||
164 | return static::CODE_SUCCESS; |
||
165 | } |
||
167 |