Conditions | 10 |
Paths | 384 |
Total Lines | 49 |
Code Lines | 30 |
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 |
||
59 | protected function execute(InputInterface $input, OutputInterface $output) |
||
60 | { |
||
61 | $cfg = $this->getSelimConfig($input); |
||
62 | $sites = $cfg->getSites(); |
||
63 | |||
64 | $filter_name = $input->getOption("filter-name"); |
||
65 | if (strlen($filter_name)) { |
||
66 | $sites = Util::filterSitesByName($sites, $filter_name); |
||
67 | } |
||
68 | |||
69 | $sspages = array(); |
||
70 | foreach ($sites as $sc) { |
||
71 | if ($sc instanceof SiteConfig) { |
||
72 | array_push($sspages, new SilverstripePage($sc)); |
||
73 | } |
||
74 | } |
||
75 | |||
76 | $filter_version = $input->getOption("filter-version"); |
||
77 | if (strlen($filter_version)) { |
||
78 | $sspages = Util::filterPagesByVersion($sspages, $filter_version); |
||
79 | } |
||
80 | |||
81 | $filter_module = $input->getOption("filter-module"); |
||
82 | if (strlen($filter_module)) { |
||
83 | $sspages = Util::filterPagesByModules($sspages, $filter_module); |
||
84 | } |
||
85 | |||
86 | if ($input->getOption("filter-da")) { |
||
87 | $sspages = Util::filterPagesByDefaultAdmin($sspages, true); |
||
88 | } |
||
89 | |||
90 | $filter_env = $input->getOption("filter-env"); |
||
91 | if ($input->getOption("filter-env")) { |
||
92 | $sspages = Util::filterPagesByEnvironmentType($sspages, $filter_env); |
||
93 | } |
||
94 | |||
95 | if ($input->getOption("table")) { |
||
96 | $out = new ConsoleOutputTable($sspages); |
||
97 | } else { |
||
98 | $out = new ConsoleOutput($sspages); |
||
99 | } |
||
100 | |||
101 | $format = $input->getOption("format"); |
||
102 | if (strlen($format)) { |
||
103 | $out->write($format); |
||
104 | } else { |
||
105 | $out->write(); |
||
106 | } |
||
107 | } |
||
108 | } |