Dopamedia/StateMachine

View on GitHub
Model/StateMachine/Builder.php

Summary

Maintainability
A
1 hr
Test Coverage

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        \Dopamedia\StateMachine\Api\ProcessEventInterface $event,
        \Dopamedia\StateMachine\Api\ProcessProcessInterface $process,
        \Dopamedia\StateMachine\Api\ProcessStateInterface $state,
        \Dopamedia\StateMachine\Api\ProcessTransitionInterface $transition,
        \Dopamedia\StateMachine\Model\ConfigurationInterface $configuration
Severity: Minor
Found in Model/StateMachine/Builder.php - About 35 mins to fix

    Function createEvents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function createEvents($processName)
        {
            $eventMap = [];
    
            if ($eventsConfiguration = $this->configuration->getEvents($processName)) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php - About 35 mins to fix

    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 assigning values to variables in if clauses and the like (line '216', column '22').
    Open

        protected function createEvent($processName, $eventName)
        {
            $event = clone $this->event;
    
            if (!is_null($command = $this->configuration->getEventCommand($processName, $eventName))) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '141', column '13').
    Open

        protected function createStates($processName, array $processMap)
        {
            $stateToProcessMap = [];
            $process = $processMap[$processName];
    
    
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '163', column '22').
    Open

        protected function createState($processName, $stateName, ProcessProcessInterface $process)
        {
            $state = clone $this->state;
            $state->setName($stateName);
            $state->setProcess($process);
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '220', column '22').
    Open

        protected function createEvent($processName, $eventName)
        {
            $event = clone $this->event;
    
            if (!is_null($command = $this->configuration->getEventCommand($processName, $eventName))) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '264', column '22').
    Open

        protected function createTransition(array $stateToProcessMap, array $eventMap, $processName, $transitionIndex)
        {
    
            $transition = clone $this->transition;
    
    
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '224', column '22').
    Open

        protected function createEvent($processName, $eventName)
        {
            $event = clone $this->event;
    
            if (!is_null($command = $this->configuration->getEventCommand($processName, $eventName))) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '212', column '22').
    Open

        protected function createEvent($processName, $eventName)
        {
            $event = clone $this->event;
    
            if (!is_null($command = $this->configuration->getEventCommand($processName, $eventName))) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '191', column '13').
    Open

        protected function createEvents($processName)
        {
            $eventMap = [];
    
            if ($eventsConfiguration = $this->configuration->getEvents($processName)) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '240', column '13').
    Open

        protected function createTransitions($processName, array $stateToProcessMap, array $processMap, array $eventMap)
        {
            if ($transitionsConfiguration = $this->configuration->getTransitions($processName)) {
                foreach (array_keys($transitionsConfiguration) as $transitionIndex) {
                    $transition = $this->createTransition($stateToProcessMap, $eventMap, $processName, $transitionIndex);
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '260', column '22').
    Open

        protected function createTransition(array $stateToProcessMap, array $eventMap, $processName, $transitionIndex)
        {
    
            $transition = clone $this->transition;
    
    
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid unused local variables such as '$stateConfiguration'.
    Open

                foreach ($statesConfiguration as $stateName => $stateConfiguration) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    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

    Avoid unused local variables such as '$eventConfiguration'.
    Open

                foreach ($eventsConfiguration as $eventName => $eventConfiguration) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    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

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

            if ($transitionsConfiguration = $this->configuration->getTransitions($processName)) {
    Severity: Minor
    Found in Model/StateMachine/Builder.php by phpmd

    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

    There are no issues that match your filters.

    Category
    Status