Conditions | 10 |
Paths | 200 |
Total Lines | 46 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | 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 |
||
49 | protected function execute(InputInterface $input, OutputInterface $output) |
||
50 | { |
||
51 | $exitCode = $this::SUCCESS_EXIT; |
||
52 | |||
53 | $applicationType = $input->getArgument('applicationType'); |
||
54 | $baseDir = $this->resolveBaseDirOption($input); |
||
55 | |||
56 | //TODO: check if absolute baseDir |
||
57 | $configFile = $input->getOption('configFile') ? getcwd() . '/' . $input->getOption('configFile') : $this->findConfigFile(); |
||
58 | //TODO: check if absolute baseDir |
||
59 | $junitFile = $input->getOption('junitFile') ? getcwd() . '/' . $input->getOption('junitFile') : null; |
||
60 | $htmlFile = $input->getOption('htmlFile') ? getcwd() . '/' . $input->getOption('htmlFile') : null; |
||
61 | |||
62 | $rulesLoader = new RulesLoader(); |
||
63 | |||
64 | try { |
||
65 | $rules = $rulesLoader->load($configFile, $applicationType, $baseDir, $input->getOption('rules')); |
||
66 | } catch (\InvalidArgumentException $e) { |
||
67 | UIHelper::displayException($e, $output); |
||
68 | |||
69 | return $this::FAILURE_EXIT; |
||
70 | } |
||
71 | |||
72 | UIHelper::displayStartingBlock($output, $configFile, $this->getApplication()->getVersion()); |
||
73 | |||
74 | foreach ($rules as $rule) { |
||
75 | try { |
||
76 | $rule->evaluate(); |
||
77 | UIHelper::displayRuleSuccess($rule, $output); |
||
78 | } catch (RuleViolationException $e) { |
||
79 | UIHelper::displayRuleViolation($e, $output); |
||
80 | } catch (\InvalidArgumentException $e) { |
||
81 | UIHelper::displayException($e, $output); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | if ($junitFile) { |
||
|
|||
86 | JunitHelper::generateJunitFile($rules, $junitFile); |
||
87 | } |
||
88 | |||
89 | if ($htmlFile) { |
||
90 | HtmlReportHelper::generateHtmlFile($rules, $htmlFile); |
||
91 | } |
||
92 | |||
93 | return $exitCode; |
||
94 | } |
||
95 | |||
120 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: