jaroslavtyc/drd-plus-tables

View on GitHub
tests/Tables/Theurgist/Spells/SpellParameters/Partials/CastingParameterTest.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '117', column '32').
Open

        $reflectionClass = new \ReflectionClass($className);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

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

        } else {
            $reflectionMethod = $reflectionClass->getMethod('getWithAddition');
            self::assertStringContainsString(<<<PHPDOC
 * @return {$classBaseName}|CastingParameter
PHPDOC

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\Tables\Tables' in method 'createSut'.
Open

        return new $sutClass($parameters, Tables::getIt());

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_get_whispered_current_casting_parameter_as_return_value_of_getter_with_addition'.
Open

        $classBaseName = StringTools::getClassBaseName($className);

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_change_initial_addition is not named in camelCase.
Open

    protected function I_can_not_change_initial_addition()
    {
        $sut = $this->createSut(['1', '2', '3' /* this should be ignored */]);
        self::assertSame(1, $sut->getValue());
        self::assertEquals(new AdditionByDifficulty('2'), $sut->getAdditionByDifficulty());

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_get_whispered_current_casting_parameter_as_return_value_of_getter_with_addition is not named in camelCase.
Open

    public function I_get_whispered_current_casting_parameter_as_return_value_of_getter_with_addition(): void
    {
        $className = static::getSutClass();
        $reflectionClass = new \ReflectionClass($className);
        $classBaseName = StringTools::getClassBaseName($className);

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_create_it is not named in camelCase.
Open

    public function I_can_create_it()
    {
        $this->I_can_create_it_negative();
        $this->I_can_create_it_with_zero();
        $this->I_can_create_it_positive();

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_create_it_with_zero is not named in camelCase.
Open

    protected function I_can_create_it_with_zero()
    {
        $sut = $this->createSut(['0', '78=321']);
        self::assertSame(0, $sut->getValue());
        self::assertEquals(new AdditionByDifficulty('78=321'), $sut->getAdditionByDifficulty());

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_create_it_positive is not named in camelCase.
Open

    protected function I_can_create_it_positive()
    {
        $sut = $this->createSut(['35689', '332211']);
        self::assertSame(35689, $sut->getValue());
        self::assertEquals(new AdditionByDifficulty('332211'), $sut->getAdditionByDifficulty());

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_its_clone_changed_by_addition is not named in camelCase.
Open

    public function I_can_get_its_clone_changed_by_addition()
    {
        $original = $this->createSut(['123', '456=789']);
        self::assertSame($original, $original->getWithAddition(0));
        $increased = $original->getWithAddition(456);

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_not_create_it_with_invalid_points_to_annotation is not named in camelCase.
Open

    public function I_can_not_create_it_with_invalid_points_to_annotation()
    {
        $this->expectException(\DrdPlus\Tables\Theurgist\Spells\SpellParameters\Partials\Exceptions\MissingValueForFormulaDifficultyAddition::class);
        $this->expectExceptionMessageMatches('~123~');
        $this->createSut([123]);

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_create_it_negative is not named in camelCase.
Open

    protected function I_can_create_it_negative()
    {
        $sut = $this->createSut(['-456', '4=6']);
        self::assertSame(-456, $sut->getValue());
        self::assertEquals(new AdditionByDifficulty('4=6'), $sut->getAdditionByDifficulty());

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_not_create_it_non_numeric is not named in camelCase.
Open

    public function I_can_not_create_it_non_numeric()
    {
        $this->expectException(\DrdPlus\Tables\Theurgist\Spells\SpellParameters\Partials\Exceptions\InvalidValueForCastingParameter::class);
        $this->expectExceptionMessageMatches('~infinite~');
        $this->createSut(['infinite', '332211']);

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