Completed
Push — master ( 456549...47da6e )
by Łukasz
02:25
created

EnvironmentLoader   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 7 1
1
<?php
2
3
namespace Tworzenieweb\SqlProvisioner\Filesystem;
4
5
6
use Dotenv\Dotenv;
7
8
/**
9
 * Class EnvironmentLoader
10
 * @package Tworzenieweb\SqlProvisioner\Filesystem
11
 */
12
class EnvironmentLoader implements EnvironmentLoaderInterface
13
{
14
    const MANDATORY_ENV_VARIABLES = [
15
        'DATABASE_USER',
16
        'DATABASE_PASSWORD',
17
        'DATABASE_NAME',
18
        'DATABASE_PORT',
19
        'DATABASE_HOST',
20
        'PROVISIONING_TABLE',
21
        'PROVISIONING_TABLE_CANDIDATE_NUMBER_COLUMN',
22
    ];
23
24
    /**
25
     * @param WorkingDirectory $currentDirectory
26
     */
27
    public function load(WorkingDirectory $currentDirectory)
28
    {
29
        $loader = new Dotenv($currentDirectory->getCurrentDirectoryAbsolute());
30
        $loader->load();
31
        $loader->required(self::MANDATORY_ENV_VARIABLES)
32
                ->notEmpty();
33
    }
34
}
35