open-orchestra/open-orchestra-cms-bundle

View on GitHub
Workflow/Tests/Form/DataTransformer/ProfileTransitionsTransformerTest.php

Summary

Maintainability
A
55 mins
Test Coverage

Function assertSameTransitions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function assertSameTransitions(array $expectedTransitions, array $flattenedTransitions)
    {
        foreach ($expectedTransitions as $transition) {
            $flattenedTransition = $transition->getStatusFrom()->getId() . '-' . $transition->getStatusTo()->getId();
            $this->assertContains($flattenedTransition, $flattenedTransitions);

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid using static access to class '\Phake' in method 'generateTransition'.
Open

        $transition = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowTransitionInterface');

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 '\Phake' in method 'generateStatus'.
Open

        $status = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

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 '\Phake' in method 'setUp'.
Open

        $this->statusRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface');

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 '\Phake' in method 'setUp'.
Open

        $transitionFactory = Phake::mock('OpenOrchestra\Workflow\Factory\TransitionFactory');

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 unused local variables such as '$transitions'.
Open

        $transitions = $this->transformer->reverseTransform($flattenedTransitions);

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Call to method when from undeclared class \Phake
Open

        Phake::when($transition)->getStatusTo()->thenReturn($statusTo);

Call to method when from undeclared class \Phake
Open

        Phake::when($transition)->getStatusFrom()->thenReturn($statusFrom);

Call to method mock from undeclared class \Phake
Open

        $status = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

Call to method mock from undeclared class \Phake
Open

        $this->statusRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface');

Return type of generateStatus() is undeclared type \OpenOrchestra\Workflow\Tests\Form\Type\Phake_IMock
Open

    protected function generateStatus($id)

Call to method when from undeclared class \Phake
Open

        Phake::when($status)->getId()->thenReturn($id);

Call to method when from undeclared class \Phake
Open

            Phake::when($this->statusRepository)->findOneById($transition->getStatusFrom()->getId())

Call to method when from undeclared class \Phake
Open

            Phake::when($this->statusRepository)->findOneById($transition->getStatusTo()->getId())

Class extends undeclared class \OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractBaseTestCase
Open

class ProfileTransitionsTransformerTest extends AbstractBaseTestCase

Call to undeclared method \OpenOrchestra\Workflow\Tests\Form\Type\ProfileTransitionsTransformerTest::assertContains
Open

            $this->assertContains($flattenedTransition, $flattenedTransitions);

Return type of generateTransition() is undeclared type \OpenOrchestra\Workflow\Tests\Form\Type\Phake_IMock
Open

    protected function generateTransition($fromId, $toId)

Call to undeclared method \OpenOrchestra\Workflow\Tests\Form\Type\ProfileTransitionsTransformerTest::assertSame
Open

        $this->assertSame($expectedTransitions, $flattenedTransitions);

Call to method mock from undeclared class \Phake
Open

        $transitionFactory = Phake::mock('OpenOrchestra\Workflow\Factory\TransitionFactory');

Call to method mock from undeclared class \Phake
Open

        $transition = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowTransitionInterface');

Call to undeclared method \OpenOrchestra\Workflow\Tests\Form\Type\ProfileTransitionsTransformerTest::assertTrue
Open

            $this->assertTrue($transitionOk);

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    protected function generateStatus($id)

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

The variable $transition_1 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $transition_3 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $transition_1 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $transition_2 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $transition_3 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $transition_2 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $transition_1 is not named in camelCase.
Open

    public function provideTransitions()
    {
        $transition_1 = $this->generateTransition('from1', 'to2');
        $transition_2 = $this->generateTransition('from2', 'to3');
        $transition_3 = $this->generateTransition('from3', 'to1');

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status