Completed
Push — master ( b3b6a4...b2f402 )
by Sergi Tur
03:43
created

SqliteEnv::sqliteEnv()   A

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
trait SqliteEnv
6
{
7
    /**
8
     * Config .env file.
9
     */
10
    protected function sqliteEnv()
11
    {
12
        passthru('sed -i \'s/^DB_/#DB_/g\' .env ', $error);
13
        if ($error !== 0) {
14
            $this->output->writeln('<error>Error commenting DB_ entries in .env file </error>');
0 ignored issues
show
Bug introduced by
The property output does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
        }
16
        passthru('sed -i \'s/.*DB_HOST.*/DB_CONNECTION=sqlite\n&/\' .env', $error);
17
        if ($error !== 0) {
18
            $this->output->writeln('<error>Error adding DB_CONNECTION=sqlite to .env file </error>');
19
        } else {
20
            $this->output->writeln('.env file updated successfully');
21
        }
22
    }
23
}
24