SilentEnvironmentLoader::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Tworzenieweb\SqlProvisioner\Filesystem;
4
5
use Dotenv\Dotenv;
6
use Dotenv\Exception\InvalidPathException;
7
8
/**
9
 * Class SilentEnvironmentLoader
10
 *
11
 * @package Tworzenieweb\SqlProvisioner\Filesystem
12
 */
13
class SilentEnvironmentLoader implements EnvironmentLoaderInterface
14
{
15
    /**
16
     * @param WorkingDirectory $currentDirectory
17
     */
18 View Code Duplication
    public function load(WorkingDirectory $currentDirectory)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        $loader = new Dotenv($currentDirectory->getCurrentDirectoryAbsolute());
21
22
        try {
23
            $loader->load();
24
        } catch (InvalidPathException $e) {
25
            // assuming .env file is missing here and then just proceed to check global env variables
26
        }
27
28
        $loader->required(EnvironmentLoader::MANDATORY_ENV_VARIABLES)
29
               ->notEmpty();
30
    }
31
}
32