| Conditions | 10 | 
| Paths | 256 | 
| Total Lines | 89 | 
| 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 | ||
| 110 | protected function interact(InputInterface $input, OutputInterface $output) | ||
| 111 |     { | ||
| 112 |         $this->io->title('EC-CUBE Installer Interactive Wizard'); | ||
| 113 | $this->io->text([ | ||
| 114 | 'If you prefer to not use this interactive wizard, define the environment valiables as follows:', | ||
| 115 | '', | ||
| 116 | ' $ export APP_ENV=dev', | ||
| 117 | ' $ export APP_DEBUG=1', | ||
| 118 | ' $ export DATABASE_URL=database_url', | ||
| 119 | ' $ export DATABASE_SERVER_VERSION=server_version', | ||
| 120 | ' $ export MAILER_URL=mailer_url', | ||
| 121 | ' $ export ECCUBE_AUTH_MAGIC=auth_magic', | ||
| 122 | ' ... and more', | ||
| 123 | ' $ php bin/console eccube:install --no-interaction', | ||
| 124 | '', | ||
| 125 | ]); | ||
| 126 | |||
| 127 | // DATABASE_URL | ||
| 128 |         $databaseUrl = $this->container->getParameter('eccube_database_url'); | ||
| 129 |         if (empty($databaseUrl)) { | ||
| 130 | $databaseUrl = 'sqlite:///var/eccube.db'; | ||
| 131 | } | ||
| 132 |         $this->envFileUpdater->databaseUrl = $this->io->ask('Database Url', $databaseUrl); | ||
| 133 | |||
| 134 | // DATABASE_SERVER_VERSION | ||
| 135 | $this->envFileUpdater->serverVersion = $this->getDatabaseServerVersion($databaseUrl); | ||
| 136 | |||
| 137 | // MAILER_URL | ||
| 138 |         $mailerUrl = $this->container->getParameter('eccube_mailer_url'); | ||
| 139 |         if (empty($mailerUrl)) { | ||
| 140 | $mailerUrl = 'null://localhost'; | ||
| 141 | } | ||
| 142 |         $this->envFileUpdater->mailerUrl = $this->io->ask('Mailer Url', $mailerUrl); | ||
| 143 | |||
| 144 | // ECCUBE_AUTH_MAGIC | ||
| 145 |         $authMagic = $this->container->getParameter('eccube_auth_magic'); | ||
| 146 |         if (empty($authMagic) || $authMagic === '<change.me>') { | ||
| 147 | $authMagic = StringUtil::random(); | ||
| 148 | } | ||
| 149 |         $this->envFileUpdater->authMagic = $this->io->ask('Auth Magic', $authMagic); | ||
| 150 | |||
| 151 | // 以下環境変数に規定済の設定値があれば利用する | ||
| 152 | // APP_ENV | ||
| 153 |         $appEnv = env('APP_ENV', 'dev'); | ||
| 154 | // .envが存在しない状態では規定値'install'となっているため、devに更新する | ||
| 155 |         if ($appEnv === 'install') { | ||
| 156 | $appEnv = 'dev'; | ||
| 157 | } | ||
| 158 | $this->envFileUpdater->appEnv = $appEnv; | ||
| 159 | |||
| 160 | // APP_DEBUG | ||
| 161 |         $this->envFileUpdater->appDebug = env('APP_DEBUG', '1'); | ||
| 162 | |||
| 163 | // ECCUBE_ADMIN_ROUTE | ||
| 164 |         $adminRoute = $this->container->getParameter('eccube_admin_route'); | ||
| 165 |         if (empty($adminRoute)) { | ||
| 166 | $adminRoute = 'admin'; | ||
| 167 | } | ||
| 168 | $this->envFileUpdater->adminRoute = $adminRoute; | ||
| 169 | |||
| 170 | // ECCUBE_TEMPLATE_CODE | ||
| 171 |         $templateCode = $this->container->getParameter('eccube_theme_code'); | ||
| 172 |         if (empty($templateCode)) { | ||
| 173 | $templateCode = 'default'; | ||
| 174 | } | ||
| 175 | $this->envFileUpdater->templateCode = $templateCode; | ||
| 176 | |||
| 177 | // ECCUBE_LOCALE | ||
| 178 |         $locale = $this->container->getParameter('locale'); | ||
| 179 |         if (empty($locale)) { | ||
| 180 | $locale = 'ja'; | ||
| 181 | } | ||
| 182 | $this->envFileUpdater->locale = $locale; | ||
| 183 | |||
| 184 |         $this->io->caution('Execute the installation process. All data is initialized.'); | ||
| 185 |         $question = new ConfirmationQuestion('Is it OK?'); | ||
| 186 |         if (!$this->io->askQuestion($question)) { | ||
| 187 | // `no`の場合はキャンセルメッセージを出力して終了する | ||
| 188 |             $this->setCode(function () { | ||
| 189 |                 $this->io->success('EC-CUBE installation stopped.'); | ||
| 190 | }); | ||
| 191 | |||
| 192 | return; | ||
| 193 | } | ||
| 194 | |||
| 195 | // envファイルへの更新反映処理 | ||
| 196 |         $this->envFileUpdater->envDir = $this->container->getParameter('kernel.project_dir'); | ||
| 197 | $this->envFileUpdater->updateEnvFile(); | ||
| 198 | } | ||
| 199 | |||
| 295 |