| Conditions | 5 |
| Paths | 16 |
| Total Lines | 80 |
| Lines | 7 |
| Ratio | 8.75 % |
| 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 |
||
| 50 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 51 | { |
||
| 52 | $em = $this->getEntityManager(null); |
||
| 53 | |||
| 54 | // for full locale code cases |
||
| 55 | $locale = env('ECCUBE_LOCALE', 'ja_JP'); |
||
| 56 | $locale = str_replace('_', '-', $locale); |
||
| 57 | $locales = \Locale::parseLocale($locale); |
||
| 58 | $localeDir = is_null($locales) ? 'ja' : $locales['language']; |
||
| 59 | |||
| 60 | $loader = new \Eccube\Doctrine\Common\CsvDataFixtures\Loader(); |
||
| 61 | $loader->loadFromDirectory(__DIR__.'/../Resource/doctrine/import_csv/'.$localeDir); |
||
| 62 | $executer = new \Eccube\Doctrine\Common\CsvDataFixtures\Executor\DbalExecutor($em); |
||
| 63 | $fixtures = $loader->getFixtures(); |
||
| 64 | $executer->execute($fixtures); |
||
| 65 | |||
| 66 | $login_id = env('ECCUBE_ADMIN_USER', 'admin'); |
||
| 67 | $login_password = env('ECCUBE_ADMIN_PASS', 'password'); |
||
| 68 | |||
| 69 | $eccubeConfig = $this->container->get(EccubeConfig::class); |
||
| 70 | $encoder = new \Eccube\Security\Core\Encoder\PasswordEncoder($eccubeConfig); |
||
| 71 | |||
| 72 | $salt = \Eccube\Util\StringUtil::random(32); |
||
| 73 | $password = $encoder->encodePassword($login_password, $salt); |
||
| 74 | |||
| 75 | $conn = $em->getConnection(); |
||
| 76 | $member_id = ('postgresql' === $conn->getDatabasePlatform()->getName()) |
||
| 77 | ? $conn->fetchColumn("select nextval('dtb_member_id_seq')") |
||
| 78 | : null; |
||
| 79 | |||
| 80 | $conn->insert('dtb_member', [ |
||
| 81 | 'id' => $member_id, |
||
| 82 | 'login_id' => $login_id, |
||
| 83 | 'password' => $password, |
||
| 84 | 'salt' => $salt, |
||
| 85 | 'work_id' => 1, |
||
| 86 | 'authority_id' => 0, |
||
| 87 | 'creator_id' => 1, |
||
| 88 | 'sort_no' => 1, |
||
| 89 | 'update_date' => new \DateTime(), |
||
| 90 | 'create_date' => new \DateTime(), |
||
| 91 | 'name' => trans('install.member_name'), |
||
| 92 | 'department' => 'EC-CUBE SHOP', |
||
| 93 | 'discriminator_type' => 'member', |
||
| 94 | ], [ |
||
| 95 | 'update_date' => \Doctrine\DBAL\Types\Type::DATETIME, |
||
| 96 | 'create_date' => \Doctrine\DBAL\Types\Type::DATETIME, |
||
| 97 | ]); |
||
| 98 | |||
| 99 | $shop_name = env('ECCUBE_SHOP_NAME', 'EC-CUBE SHOP'); |
||
| 100 | $admin_mail = env('ECCUBE_ADMIN_MAIL', '[email protected]'); |
||
| 101 | |||
| 102 | $id = ('postgresql' === $conn->getDatabasePlatform()->getName()) |
||
| 103 | ? $conn->fetchColumn("select nextval('dtb_base_info_id_seq')") |
||
| 104 | : null; |
||
| 105 | |||
| 106 | $conn->insert('dtb_base_info', [ |
||
| 107 | 'id' => $id, |
||
| 108 | 'shop_name' => $shop_name, |
||
| 109 | 'email01' => $admin_mail, |
||
| 110 | 'email02' => $admin_mail, |
||
| 111 | 'email03' => $admin_mail, |
||
| 112 | 'email04' => $admin_mail, |
||
| 113 | 'update_date' => new \DateTime(), |
||
| 114 | 'discriminator_type' => 'baseinfo', |
||
| 115 | ], [ |
||
| 116 | 'update_date' => \Doctrine\DBAL\Types\Type::DATETIME, |
||
| 117 | ]); |
||
| 118 | |||
| 119 | $faviconPath = '/assets/img/common/favicon.ico'; |
||
| 120 | View Code Duplication | if (!file_exists($this->container->getParameter('eccube_html_dir').'/user_data'.$faviconPath)) { |
|
| 121 | $file = new Filesystem(); |
||
| 122 | $file->copy( |
||
| 123 | $this->container->getParameter('eccube_html_front_dir').$faviconPath, |
||
| 124 | $this->container->getParameter('eccube_html_dir').'/user_data'.$faviconPath |
||
| 125 | ); |
||
| 126 | } |
||
| 127 | |||
| 128 | $output->writeln(sprintf(' <comment>></comment> <info>%s</info>', 'Finished Successful!')); |
||
| 129 | } |
||
| 130 | } |
||
| 131 |