Code Duplication    Length = 20-22 lines in 2 locations

src/Console/Installer.php 2 locations

@@ 196-215 (lines=20) @@
193
     *
194
     * @return void
195
     */
196
    public static function setDatabaseName($dir, $io)
197
    {
198
        $config = $dir . '/config/app.php';
199
        $content = file_get_contents($config);
200
201
        $databaseName = $io->ask('What is your new database name ? ', 'xeta');
202
        $content = str_replace('__DATABASE__', $databaseName, $content, $count);
203
204
        if ($count == 0) {
205
            $io->write('No Datasources.default.database placeholder to replace.');
206
207
            return;
208
        }
209
210
        $result = file_put_contents($config, $content);
211
        if ($result) {
212
            $io->write('Updated Datasources.default.database value in config/app.php');
213
214
            return;
215
        }
216
        $io->write('Unable to update Datasources.default.database value.');
217
    }
218
@@ 226-247 (lines=22) @@
223
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
224
     * @return void
225
     */
226
    public static function setSecuritySalt($dir, $io)
227
    {
228
        $config = $dir . '/config/app.php';
229
        $content = file_get_contents($config);
230
231
        $newKey = hash('sha256', Security::randomBytes(64));
232
        $content = str_replace('__SALT__', $newKey, $content, $count);
233
234
        if ($count == 0) {
235
            $io->write('No Security.salt placeholder to replace.');
236
237
            return;
238
        }
239
240
        $result = file_put_contents($config, $content);
241
        if ($result) {
242
            $io->write('Updated Security.salt value in config/app.php');
243
244
            return;
245
        }
246
        $io->write('Unable to update Security.salt value.');
247
    }
248
249
    /**
250
     * Set up the admin and member password for the database.