jaroslavtyc/drd-plus-health

View on GitHub
tests/Health/Afflictions/AfflictionSourceTest.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using static access to class '\Granam\String\StringTools' in method 'I_can_get_every_source'.
Open

        $isTypeSource = StringTools::assembleGetterForName($source, 'is');

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 '\Granam\String\StringTools' in method 'I_can_get_every_source'.
Open

            $isOtherTypeSource = StringTools::assembleGetterForName($otherSourceCode, 'is');

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 '\Granam\String\StringTools' in method 'I_can_get_every_source'.
Open

        $getSource = StringTools::assembleGetterForName($sourceCode) . 'Source';

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 '\DrdPlus\Health\Afflictions\AfflictionSource' in method 'I_can_get_every_source'.
Open

        $source = AfflictionSource::$getSource();

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

The method I_can_get_every_source uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            self::assertFalse($source->isDeformation(), "Expected source {$source} to be a deformation");
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\DrdPlus\Health\Afflictions\AfflictionSource' in method 'I_can_get_every_source'.
Open

        self::assertSame($source, AfflictionSource::getIt($sourceCode));

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 '\DrdPlus\Health\Afflictions\AfflictionSource' in method 'I_can_not_create_custom_source'.
Open

        AfflictionSource::getEnum('heavy metal');

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

The method I_can_not_create_custom_source is not named in camelCase.
Open

    public function I_can_not_create_custom_source()
    {
        $this->expectException(\DrdPlus\Health\Afflictions\Exceptions\UnknownAfflictionSource::class);
        $this->expectExceptionMessageMatches('~heavy metal~');
        AfflictionSource::getEnum('heavy metal');

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method I_can_get_every_source is not named in camelCase.
Open

    public function I_can_get_every_source($sourceCode, $isSomeDeformation)
    {
        $getSource = StringTools::assembleGetterForName($sourceCode) . 'Source';
        /** @var AfflictionSource $source */
        $source = AfflictionSource::$getSource();

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status