BuildLoadEnvironmentVariables   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 27
rs 10
ccs 6
cts 6
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A bootstrap() 0 7 2
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