Conditions | 12 |
Paths | 66 |
Total Lines | 58 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 10 | ||
Bugs | 0 | Features | 2 |
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 |
||
50 | protected function execute(InputInterface $input, OutputInterface $output) |
||
51 | { |
||
52 | |||
53 | $headerStyle = new OutputFormatterStyle('white', 'green', |
||
54 | array('bold')); |
||
55 | $output->getFormatter()->setStyle('header', $headerStyle); |
||
56 | |||
57 | $site = $input->getArgument('site'); |
||
58 | $output->writeln('<header>Checking ' . $site . '... </header>'); |
||
59 | $site = new Asset($site); |
||
60 | |||
61 | $verbosityLevelMap = []; |
||
62 | if ($input->getOption('log-success')) { |
||
63 | $verbosityLevelMap = array( |
||
64 | LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL, |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | $logger = new ConsoleLogger($output, $verbosityLevelMap); |
||
69 | $observer = new ConsoleObserver($logger); |
||
70 | $siteChecker = SiteChecker::create($observer); |
||
71 | |||
72 | if ($input->getOptions()) { |
||
73 | $config = new Config(); |
||
74 | |||
75 | // Load configuration from file if any |
||
76 | $conf = json_decode(file_get_contents(__DIR__ . CONFIG_PATH)); |
||
77 | $siteConf = isset($conf->{$site->host}) ? $conf->{$site->host} : null; |
||
78 | |||
79 | if (!is_null($siteConf) || !is_null($conf)) { |
||
80 | foreach ((array)$config as $key => $value) { |
||
81 | // First use general values |
||
82 | if (!empty($conf->{$key})) { |
||
83 | $config->{$key} = $conf->{$key}; |
||
84 | } |
||
85 | // Then rewrite them with site-specific |
||
86 | if (!empty($siteConf->{$key})) { |
||
87 | $config->{$key} = $siteConf->{$key}; |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | |||
92 | if ($input->getOption('log-success')) { |
||
93 | $config->showOnlyProblems = false; |
||
94 | } |
||
95 | |||
96 | if ($input->getOption('check-external')) { |
||
97 | $config->checkExternal = true; |
||
98 | } |
||
99 | |||
100 | if ($input->getOption('full-html')) { |
||
101 | $config->showFullTags = true; |
||
102 | } |
||
103 | $siteChecker->setConfig($config); |
||
104 | $observer->setConfig($config); |
||
105 | } |
||
106 | $siteChecker->check($site); |
||
107 | } |
||
108 | } |
||
109 |