InteractsWithEnvironment::addValueToEnv()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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