| Conditions | 16 |
| Paths | 35 |
| Total Lines | 95 |
| Code Lines | 56 |
| Lines | 39 |
| Ratio | 41.05 % |
| 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 |
||
| 70 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 71 | { |
||
| 72 | |||
| 73 | /** @var \Eccube\Application $app */ |
||
| 74 | $app = $this->getSilexApplication(); |
||
| 75 | |||
| 76 | $filter = $input->getArgument('filter'); |
||
| 77 | |||
| 78 | $optional = $input->getOption('configphp'); |
||
| 79 | if ($optional) { |
||
| 80 | // ymlファイルではなく、phpファイルが有効になっているかチェック |
||
| 81 | $ymlPath = $this->getProjectDirectory().'/app/config/eccube'; |
||
| 82 | $config_php = $ymlPath.'/config.php'; |
||
| 83 | if (file_exists($config_php)) { |
||
| 84 | $output->writeln('Config PHP File : <info>used.</info>'); |
||
| 85 | } else { |
||
| 86 | $output->writeln('Config PHP File : <info>not used.</info>'); |
||
| 87 | } |
||
| 88 | |||
| 89 | if (!$filter) { |
||
| 90 | return; |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | $recursive = function ($config, $space = ' ') use (&$recursive, $output) { |
||
| 95 | foreach ($config as $key => $item) { |
||
| 96 | if (is_array($item)) { |
||
| 97 | $space = ' '; |
||
| 98 | $output->writeln($space."<comment>{$key}</comment> :"); |
||
| 99 | $space .= ' '; |
||
| 100 | |||
| 101 | $recursive($item, $space); |
||
| 102 | } else { |
||
| 103 | $output->writeln($space."<comment>{$key}</comment> : <info>{$item}</info>"); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | }; |
||
| 107 | |||
| 108 | |||
| 109 | if ($filter) { |
||
| 110 | // コマンド実行時にパラメータを指定 |
||
| 111 | |||
| 112 | $config = array(); |
||
| 113 | $app->parseConfig($filter, $config); |
||
| 114 | |||
| 115 | View Code Duplication | if (!empty($config)) { |
|
| 116 | // ymlファイル名が指定された場合、ymlファイルの内容を出力 |
||
| 117 | $output->writeln("YML File Name : <info>{$filter}</info>"); |
||
| 118 | foreach ($config as $key => $item) { |
||
| 119 | if (is_array($item)) { |
||
| 120 | $output->writeln("<comment>{$key}</comment> :"); |
||
| 121 | $recursive($item); |
||
| 122 | } else { |
||
| 123 | $output->writeln("<comment>{$key}</comment> : <info>{$item}</info>"); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | return; |
||
| 128 | } |
||
| 129 | |||
| 130 | if (!isset($app['config'][$filter])) { |
||
| 131 | $output->writeln('Not Found filter : $app[\'config\'][\'<error>'.$filter.'</error>\']'); |
||
| 132 | |||
| 133 | return; |
||
| 134 | } |
||
| 135 | |||
| 136 | $config = $app['config'][$filter]; |
||
| 137 | |||
| 138 | $output->writeln('$app[\'config\'][\'<comment>'.$filter.'</comment>\']'); |
||
| 139 | View Code Duplication | if (is_array($config)) { |
|
| 140 | foreach ($config as $key => $item) { |
||
| 141 | if (is_array($item)) { |
||
| 142 | $output->writeln("<comment>{$key}</comment> :"); |
||
| 143 | $recursive($item); |
||
| 144 | } else { |
||
| 145 | $output->writeln("<comment>{$key}</comment> : <info>{$item}</info>"); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | } else { |
||
| 149 | $output->writeln("<comment>{$filter}</comment> : <info>{$config}</info>"); |
||
| 150 | } |
||
| 151 | View Code Duplication | } else { |
|
| 152 | // $app['config']の内容を全て出力する |
||
| 153 | $config = $app['config']; |
||
| 154 | |||
| 155 | foreach ($config as $key => $item) { |
||
| 156 | if (is_array($item)) { |
||
| 157 | $output->writeln("<comment>{$key}</comment> :"); |
||
| 158 | $recursive($item); |
||
| 159 | } else { |
||
| 160 | $output->writeln("<comment>{$key}</comment> : <info>{$item}</info>"); |
||
| 161 | } |
||
| 162 | } |
||
| 163 | } |
||
| 164 | } |
||
| 165 | } |
||
| 166 |