pluf/workflow

View on GitHub
src/Imp/TransitionImpl.php

Summary

Maintainability
C
1 day
Test Coverage

Function doTransitInternal has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function doTransitInternal(ImmutableState $source, ImmutableState $target, StateContext $stateContext): void
    {
        if ($source == $this->getTargetState()) {
            // Handles 1.
            // Handles 3. after traversing from the source to the target.
Severity: Minor
Found in src/Imp/TransitionImpl.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

TransitionImpl has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class TransitionImpl implements MutableTransition
{

    public ImmutableState $sourceState;

Severity: Minor
Found in src/Imp/TransitionImpl.php - About 2 hrs to fix

    Method doTransitInternal has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function doTransitInternal(ImmutableState $source, ImmutableState $target, StateContext $stateContext): void
        {
            if ($source == $this->getTargetState()) {
                // Handles 1.
                // Handles 3. after traversing from the source to the target.
    Severity: Minor
    Found in src/Imp/TransitionImpl.php - About 1 hr to fix

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

          public function isMatch($fromState, $toState, $event, int $priority, ?string $condClazz = null, ?string $type = null): bool
          {
              $flag = true;
              if ($toState == null && ! $this->getTargetState()->isFinalState())
                  $flag = false;
      Severity: Minor
      Found in src/Imp/TransitionImpl.php - About 55 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

      Method isMatch has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function isMatch($fromState, $toState, $event, int $priority, ?string $condClazz = null, ?string $type = null): bool
      Severity: Minor
      Found in src/Imp/TransitionImpl.php - About 45 mins to fix

        Avoid too many return statements within this method.
        Open

                return true;
        Severity: Major
        Found in src/Imp/TransitionImpl.php - About 30 mins to fix

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

              public function internalFire(StateContext $stateContext): void
              {
                  // Fix issue17
                  if ($this->type == TransitionType::INTERNAL && $stateContext->getSourceState()->getStateId() != $this->targetState->getStateId()) {
                      return;
          Severity: Minor
          Found in src/Imp/TransitionImpl.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