pluf/workflow

View on GitHub
src/Imp/StateImpl.php

Summary

Maintainability
F
4 days
Test Coverage

File StateImpl.php has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Pluf\Workflow\Imp;

use Pluf\Workflow\HistoryType;
use Pluf\Workflow\ImmutableState;
Severity: Minor
Found in src/Imp/StateImpl.php - About 7 hrs to fix

    Function internalFire has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        public function internalFire($stateContext): void
        {
            $currentTransitionResult = $stateContext->getResult();
            if ($this->isParallelState()) {
                /*
    Severity: Minor
    Found in src/Imp/StateImpl.php - About 7 hrs 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

    StateImpl has 50 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class StateImpl implements MutableState
    {
    
        // private static final Logger logger = LoggerFactory.getLogger(StateImpl.class);
        protected $stateId;
    Severity: Minor
    Found in src/Imp/StateImpl.php - About 7 hrs to fix

      Function exit has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function exit(StateContext $stateContext): void
          {
              if ($this->isParallelState()) {
                  $subStates = $this->getSubStatesOn($this, $stateContext->getStateMachineData()
                      ->read());
      Severity: Minor
      Found in src/Imp/StateImpl.php - About 3 hrs 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

      Method internalFire has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function internalFire($stateContext): void
          {
              $currentTransitionResult = $stateContext->getResult();
              if ($this->isParallelState()) {
                  /*
      Severity: Major
      Found in src/Imp/StateImpl.php - About 2 hrs to fix

        Function checkConflictTransitions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function checkConflictTransitions(ImmutableTransition $target, array $allTransitions): ?ImmutableTransition
            {
                foreach ($allTransitions as $t) {
                    if ($target == $t || $t->getCondition()::class == Never::class/* Conditions::Never::class */) {
                        continue;
        Severity: Minor
        Found in src/Imp/StateImpl.php - About 2 hrs 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

        Method exit has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function exit(StateContext $stateContext): void
            {
                if ($this->isParallelState()) {
                    $subStates = $this->getSubStatesOn($this, $stateContext->getStateMachineData()
                        ->read());
        Severity: Minor
        Found in src/Imp/StateImpl.php - About 1 hr to fix

          Function verify has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function verify(): void
              {
                  if ($this->isFinalState()) {
                      if ($this->isParallelState()) {
                          throw new IllegalStateException("Final state cannot be parallel state.");
          Severity: Minor
          Found in src/Imp/StateImpl.php - About 1 hr 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

          Function enterByHistory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function enterByHistory($stateContext): ImmutableState
              {
                  if ($this->finalState || $this->isParallelState()) // no historical info
                      return this;
          
          
          Severity: Minor
          Found in src/Imp/StateImpl.php - About 25 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

          There are no issues that match your filters.

          Category
          Status