Passed
Push — master ( 247a52...f18ab4 )
by Melech
07:21 queued 03:19
created

Config::setPropertiesBeforeSettingFromEnv()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 3
nc 4
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Asset;
15
16
use Valkyrja\Asset\Config\Bundles;
17
use Valkyrja\Asset\Config\DefaultBundle;
18
use Valkyrja\Asset\Constant\ConfigName;
0 ignored issues
show
Bug introduced by
The type Valkyrja\Asset\Constant\ConfigName 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...
19
use Valkyrja\Asset\Constant\EnvName;
0 ignored issues
show
Bug introduced by
The type Valkyrja\Asset\Constant\EnvName 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...
20
use Valkyrja\Config\Config as ParentConfig;
21
22
use function array_key_first;
23
24
/**
25
 * Class Config.
26
 *
27
 * @author Melech Mizrachi
28
 */
29
class Config extends ParentConfig
30
{
31
    /**
32
     * @inheritDoc
33
     *
34
     * @var array<string, string>
35
     */
36
    protected static array $envNames = [
37
        ConfigName::DEFAULT_BUNDLE => EnvName::DEFAULT_BUNDLE,
38
    ];
39
40
    public function __construct(
41
        public string $defaultBundle = '',
42
        public Bundles|null $bundles = null,
43
    ) {
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function setPropertiesFromEnv(string $env): void
50
    {
51
        if ($this->bundles === null) {
52
            $this->bundles = new Bundles(
53
                default: DefaultBundle::fromEnv($env),
54
            );
55
        }
56
57
        if ($this->defaultBundle === '') {
58
            $this->defaultBundle = (string) array_key_first((array) $this->bundles);
59
        }
60
61
        parent::setPropertiesFromEnv($env);
62
    }
63
}
64