Dotenv   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 14 3
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