Passed
Pull Request — master (#67)
by Dmitriy
36:12 queued 21:07
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 6
cp 0
rs 10
cc 3
nc 3
nop 2
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Reader;
6
7
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...
8
use Yiisoft\Composer\Config\Exception\UnsupportedFileTypeException;
9
10
/**
11
 * EnvReader - reads `.env` files.
12
 */
13
class EnvReader extends AbstractReader
14
{
15
    protected function readRaw(string $path)
16
    {
17
        if (!class_exists(Dotenv::class)) {
18
            throw new UnsupportedFileTypeException('for .env support require `vlucas/phpdotenv` in your composer.json');
19
        }
20
        $info = pathinfo($path);
21
22
        return array_merge(
23
            getenv(),
0 ignored issues
show
Bug introduced by
getenv() of type string is incompatible with the type array expected by parameter $array1 of array_merge(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
            /** @scrutinizer ignore-type */ getenv(),
Loading history...
24
            Dotenv::createMutable($info['dirname'], $info['basename'])->load()
25
        );
26
    }
27
}
28