Passed
Pull Request — master (#67)
by Dmitriy
15:55 queued 59s
created

EnvReader::loadEnvs()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 10
cc 3
nc 3
nop 2
crap 12
1
<?php
2
3
namespace Yiisoft\Composer\Config\Reader;
4
5
use Dotenv\Dotenv;
0 ignored issues
show
Bug introduced by
The type Dotenv\Dotenv was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Yiisoft\Composer\Config\Exception\UnsupportedFileTypeException;
7
8
/**
9
 * EnvReader - reads `.env` files.
10
 */
11
class EnvReader extends AbstractReader
12
{
13
    protected function readRaw(string $path)
14
    {
15
        if (!class_exists(Dotenv::class)) {
16
            throw new UnsupportedFileTypeException('for .env support require `vlucas/phpdotenv` in your composer.json');
17
        }
18
        $info = pathinfo($path);
19
        Dotenv::createImmutable($info['dirname'], $info['basename'])->load();
20
        return getenv();
21
    }
22
}
23