BuildLoadEnvironmentVariables::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Laravel Zero.
7
 *
8
 * (c) Nuno Maduro <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace LaravelZero\Framework\Bootstrap;
15
16
use Dotenv\Dotenv;
17
use LaravelZero\Framework\Application;
18
use LaravelZero\Framework\Contracts\BoostrapperContract;
19
use LaravelZero\Framework\Providers\Build\Build;
20
21
/**
22
 * @internal
23
 */
24
final class BuildLoadEnvironmentVariables implements BoostrapperContract
25
{
26
    /**
27
     * @var \LaravelZero\Framework\Providers\Build\Build
28
     */
29
    private $build;
30
31
    /**
32
     * BuildLoadEnvironmentVariables constructor.
33
     *
34
     * @param \LaravelZero\Framework\Providers\Build\Build $build
35
     */
36 39
    public function __construct(Build $build)
37
    {
38 39
        $this->build = $build;
39 39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 39
    public function bootstrap(Application $app): void
45
    {
46
        /*
47
         * Override environment variables with the environment file along side the Phar file.
48
         */
49 39
        if ($this->build->shouldUseEnvironmentFile()) {
50 1
            Dotenv::create($this->build->getDirectoryPath(), $this->build->environmentFile())->overload();
51
        }
52 39
    }
53
}
54