SqliteEnv::sqliteEnv()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 9
nc 4
nop 0
1
<?php
2
3
namespace Acacha\Llum\Traits;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
/**
8
 * Class SqliteEnv.
9
 *
10
 * @property OutputInterface $output
11
 */
12
trait SqliteEnv
13
{
14
    /**
15
     * Config .env file.
16
     */
17
    protected function sqliteEnv()
18
    {
19
        passthru('sed -i \'s/^DB_/#DB_/g\' .env ', $error);
20
        if ($error !== 0) {
21
            $this->output->writeln('<error>Error commenting DB_ entries in .env file </error>');
22
        }
23
        passthru('sed -i \'s/.*DB_HOST.*/DB_CONNECTION=sqlite\n&/\' .env', $error);
24
        if ($error !== 0) {
25
            $this->output->writeln('<error>Error adding DB_CONNECTION=sqlite to .env file </error>');
26
        } else {
27
            $this->output->writeln('.env file updated successfully');
28
        }
29
    }
30
}
31