InteractsWithEnvironment   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A addValueToEnv() 0 7 1
1
<?php
2
3
namespace Acacha\ForgePublish\Commands\Traits;
4
5
use Illuminate\Support\Facades\File;
6
7
/**
8
 * Trait InteractsWithEnvironment
9
 *
10
 * @package Acacha\ForgePublish\Commands
11
 */
12
trait InteractsWithEnvironment
13
{
14
    /**
15
     * Add value to env.
16
     *
17
     * @param $key
18
     * @param $value
19
     */
20
    protected function addValueToEnv($key, $value)
21
    {
22
        $env_path = base_path('.env');
23
        $sed_command = "/bin/sed -i '/^$key=/d' " . $env_path;
24
        passthru($sed_command);
25
        File::append($env_path, "\n$key=$value\n");
26
    }
27
}
28