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

EnvironmentLoader::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 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