MontealegreLuis/php-testing-tools

View on GitHub
ewallet/src/Application/Environment.php

Summary

Maintainability
A
0 mins
Test Coverage

load accesses the super-global variable $_ENV.
Open

    private static function load(BasePath $basePath): void
    {
        if (! isset($_ENV['APP_ENV'])) {
            $environment = Dotenv::createImmutable($basePath->absolutePath());
            $environment->load();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

fromGlobals accesses the super-global variable $_ENV.
Open

    public static function fromGlobals(BasePath $basePath): Environment
    {
        self::load($basePath);
        $name = trim($_ENV['APP_ENV'] ?? 'local');
        $envDebug = trim($_ENV['APP_DEBUG'] ?? 'false');

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

fromGlobals accesses the super-global variable $_ENV.
Open

    public static function fromGlobals(BasePath $basePath): Environment
    {
        self::load($basePath);
        $name = trim($_ENV['APP_ENV'] ?? 'local');
        $envDebug = trim($_ENV['APP_DEBUG'] ?? 'false');

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Avoid using static access to class '\Dotenv\Dotenv' in method 'load'.
Open

            $environment = Dotenv::createImmutable($basePath->absolutePath());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Webmozart\Assert\Assert' in method 'setName'.
Open

        Assert::oneOf(
            $name,
            ['local', 'test', 'dev', 'prod'],
            'Expected one of the valid application environments: %2$s. Got %s'
        );

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

There are no issues that match your filters.

Category
Status