DotEnvFactory::createFromEnvironmentVariable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Abacaphiliac\ZendPhpDotEnv;
4
5
use Dotenv\Dotenv;
6
7
class DotEnvFactory
8
{
9
    /**
10
     * @param string $name
11
     * @param string $file
12
     * @return Dotenv
13
     */
14 1
    public static function createFromConstant($name, $file)
15
    {
16 1
        $path = constant($name);
17
18 1
        return self::create($path, $file);
19
    }
20
21
    /**
22
     * @param string $name
23
     * @param string $file
24
     * @return Dotenv
25
     */
26 1
    public static function createFromEnvironmentVariable($name, $file)
27
    {
28 1
        $path = DotEnvLoader::getEnvironmentVariable($name);
29
30 1
        return self::create($path, $file);
31
    }
32
33
    /**
34
     * @param string $file
35
     * @return Dotenv
36
     */
37 1
    public static function createFromWorkingDirectory($file)
38 1
    {
39 1
        $path = getcwd();
40
41 1
        return self::create($path, $file);
42
    }
43
44
    /**
45
     * @param string $path
46
     * @param string $file
47
     * @return Dotenv
48
     */
49 4
    public static function create($path, $file)
50
    {
51 4
        return new Dotenv($path, $file);
52
    }
53
}
54