jaroslavtyc/doctrineum-integer

View on GitHub
Doctrineum/Tests/Integer/IntegerEnumTypeTest.php

Summary

Maintainability
A
3 hrs
Test Coverage

IntegerEnumTypeTest has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class IntegerEnumTypeTest extends AbstractSelfRegisteringTypeTest
{

    /**
     * @throws \Doctrine\DBAL\DBALException
Severity: Minor
Found in Doctrineum/Tests/Integer/IntegerEnumTypeTest.php - About 3 hrs to fix

    The class IntegerEnumTypeTest has 23 public methods. Consider refactoring IntegerEnumTypeTest to keep number of public methods under 10.
    Open

    class IntegerEnumTypeTest extends AbstractSelfRegisteringTypeTest
    {
    
        /**
         * @throws \Doctrine\DBAL\DBALException

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    Missing class import via use statement (line '233', column '49').
    Open

            $integerEnumType->convertToPHPValue(new \stdClass(), $this->getAbstractPlatform());

    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

    Avoid using static access to class '\Doctrine\DBAL\Types\Type' in method 'tearDown'.
    Open

            $integerEnumType = Type::getType($this->getExpectedTypeName());

    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 '\Mockery' in method 'subtype_returns_proper_enum'.
    Open

            $abstractPlatform = \Mockery::mock(AbstractPlatform::class);

    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 '\Mockery' in method 'getPlatform'.
    Open

            return \Mockery::mock(AbstractPlatform::class);

    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 '\Doctrine\DBAL\Types\Type' in method 'different_types_with_same_subtype_regexp_distinguish_them'.
    Open

            $integerEnumType = Type::getType($this->getExpectedTypeName());

    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 '\Mockery' in method 'getAbstractPlatform'.
    Open

            return \Mockery::mock(AbstractPlatform::class);

    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 '\Mockery' in method 'default_enum_is_given_if_subtype_does_not_match'.
    Open

            $abstractPlatform = \Mockery::mock(AbstractPlatform::class);

    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 '\Doctrine\DBAL\Types\Type' in method 'setUp'.
    Open

            if (!Type::hasType($this->getExpectedTypeName())) {

    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 '\Doctrine\DBAL\Types\Type' in method 'setUp'.
    Open

                Type::addType($this->getExpectedTypeName(), $this->getTypeClass());

    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 '\Mockery' in method 'enum_as_database_value_is_integer_value_of_that_enum'.
    Open

            $enum = \Mockery::mock(ScalarEnumInterface::class);

    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 '\Doctrine\DBAL\Types\Type' in method 'different_types_with_same_subtype_regexp_distinguish_them'.
    Open

            $anotherEnumType = Type::getType($this->getExpectedTypeName($anotherEnumTypeClass));

    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 excessively long variable names like $matchingValueToConvert. Keep variable name length under 20.
    Open

            $matchingValueToConvert = 123456789;

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $nonMatchingValueToConvert. Keep variable name length under 20.
    Open

            $nonMatchingValueToConvert = 99999999;

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    The method can_register_subtype is not named in camelCase.
    Open

        public function can_register_subtype(IntegerEnumType $integerEnumType)
        {
            self::assertTrue($integerEnumType::addSubTypeEnum($this->getSubTypeEnumClass(), '~foo~'));
            self::assertTrue($integerEnumType::hasSubTypeEnum($this->getSubTypeEnumClass()));
    
    

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

        public function registering_subtype_with_invalid_regexp_throws_exception(IntegerEnumType $integerEnumType)
        {
            $integerEnumType::addSubTypeEnum($this->getSubTypeEnumClass(), 'foo~' /* missing opening delimiter */);
        }

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

        public function enum_as_database_value_is_integer_value_of_that_enum(IntegerEnumType $integerEnumType): void
        {
            $enum = \Mockery::mock(ScalarEnumInterface::class);
            /** @noinspection PhpMethodParametersCountMismatchInspection */
            $enum->shouldReceive('getValue')

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

        public function default_enum_is_given_if_subtype_does_not_match(IntegerEnumType $integerEnumType)
        {
            self::assertTrue($integerEnumType::addSubTypeEnum($this->getSubTypeEnumClass(), $regexp = '~456~'));
            /** @var AbstractPlatform $abstractPlatform */
            $abstractPlatform = \Mockery::mock(AbstractPlatform::class);

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

        public function It_raises_an_exception_if_get_empty_string_from_database(IntegerEnumType $integerEnumType): void
        {
            $integerEnumType->convertToPHPValue('', $this->getAbstractPlatform());
        }

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

        public function object_to_php_value_cause_exception(IntegerEnumType $integerEnumType)
        {
            $integerEnumType->convertToPHPValue(new \stdClass(), $this->getAbstractPlatform());
        }

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

        public function true_to_php_gives_one(IntegerEnumType $integerEnumType)
        {
            $enum = $integerEnumType->convertToPHPValue(true, $this->getAbstractPlatform());
            self::assertSame(1, $enum->getValue());
            self::assertSame('1', (string)$enum);

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

        public function can_unregister_subtype(IntegerEnumType $integerEnumType)
        {
            /**
             * The subtype is unregistered because of tearDown clean up
             *

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

        public function I_can_get_instance(): IntegerEnumType
        {
            $enumTypeClass = $this->getTypeClass();
            $instance = $enumTypeClass::getType($this->getExpectedTypeName());
            self::assertInstanceOf($enumTypeClass, $instance);

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

        public function integer_to_php_value_gives_enum_with_that_integer(IntegerEnumType $integerEnumType): void
        {
            $enum = $integerEnumType->convertToPHPValue($integer = 12345, $this->getAbstractPlatform());
            self::assertInstanceOf($this->getRegisteredClass(), $enum);
            self::assertSame($integer, $enum->getValue());

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

        public function I_get_null_if_fetched_from_database(IntegerEnumType $integerEnumType): void
        {
            self::assertNull($integerEnumType->convertToPHPValue(null, $this->getAbstractPlatform()));
        }

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

        public function callback_to_php_value_cause_exception(IntegerEnumType $integerEnumType)
        {
            $integerEnumType->convertToPHPValue(function () {
            }, $this->getAbstractPlatform());
        }

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

        public function sql_default_length_is_ten(IntegerEnumType $integerEnumType): void
        {
            $defaultLength = $integerEnumType->getDefaultLength($this->getAbstractPlatform());
            self::assertSame(10, $defaultLength);
        }

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

        public function resource_to_php_value_cause_exception(IntegerEnumType $integerEnumType)
        {
            $integerEnumType->convertToPHPValue(tmpfile(), $this->getAbstractPlatform());
        }

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

        public function registering_same_subtype_again_throws_exception(IntegerEnumType $integerEnumType)
        {
            self::assertFalse($integerEnumType::hasSubTypeEnum($this->getSubTypeEnumClass()));
            self::assertTrue($integerEnumType::addSubTypeEnum($this->getSubTypeEnumClass(), '~foo~'));
            // registering twice - should thrown an exception

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

        public function different_types_with_same_subtype_regexp_distinguish_them()
        {
            /** @var IntegerEnumType $enumTypeClass */
            $enumTypeClass = $this->getTypeClass();
            if ($enumTypeClass::hasSubTypeEnum($this->getSubTypeEnumClass())) {

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

        public function string_integer_to_php_value_gives_enum_with_that_integer(IntegerEnumType $integerEnumType): void
        {
            $enum = $integerEnumType->convertToPHPValue($stringInteger = '12345', $this->getAbstractPlatform());
            self::assertInstanceOf($this->getRegisteredClass(), $enum);
            self::assertSame((int)$stringInteger, $enum->getValue());

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

        public function false_to_php_value_gives_zero(IntegerEnumType $integerEnumType)
        {
            $enum = $integerEnumType->convertToPHPValue(false, $this->getAbstractPlatform());
            self::assertSame(0, $enum->getValue());
            self::assertSame('0', (string)$enum);

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

        public function array_to_php_value_cause_exception(IntegerEnumType $integerEnumType)
        {
            /** @noinspection PhpParamsInspection */
            $integerEnumType->convertToPHPValue([], $this->getAbstractPlatform());
        }

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

        public function subtype_returns_proper_enum(IntegerEnumType $integerEnumType)
        {
            self::assertTrue($integerEnumType::addSubTypeEnum($this->getSubTypeEnumClass(), $regexp = '~456~'));
            /** @var AbstractPlatform $abstractPlatform */
            $abstractPlatform = \Mockery::mock(AbstractPlatform::class);

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

        public function sql_declaration_is_valid(IntegerEnumType $integerEnumType): void
        {
            $sql = $integerEnumType->getSQLDeclaration([], $this->getAbstractPlatform());
            self::assertSame('INTEGER', $sql);
        }

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

        public function float_to_php_value_cause_exception(IntegerEnumType $integerEnumType)
        {
            $integerEnumType->convertToPHPValue(12345.6789, $this->getAbstractPlatform());
        }

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

        public function zero_float_to_php_gives_zero(IntegerEnumType $integerEnumType)
        {
            $enum = $integerEnumType->convertToPHPValue(0.0, $this->getAbstractPlatform());
            self::assertSame(0, $enum->getValue());
            self::assertSame('0', (string)$enum);

    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