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

SqliteEnv   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A sqliteEnv() 0 13 3
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