Dotenv::load()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Dotenv;
6
7
use Dotenv\Dotenv as PhpDotenv;
8
9
use function file_exists;
10
use function realpath;
11
use function sprintf;
12
13
final class Dotenv
14
{
15
    public function load(string $dir): void
16
    {
17
        if (file_exists((string) realpath(sprintf('%s/.env', $dir)))) {
18
            PhpDotenv::createImmutable($dir)->load();
19
20
            return;
21
        }
22
23
        if (! file_exists((string) realpath(sprintf('%s/.env.dist', $dir)))) {
24
            return;
25
        }
26
27
        (PhpDotenv::createImmutable($dir, '.env.dist'))->load();
28
    }
29
}
30