SilentEnvironmentLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 68.42 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 13
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 13 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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