pluf/workflow

View on GitHub
src/Imp/StateMachineImpl.php

Summary

Maintainability
F
3 days
Test Coverage

StateMachineImpl has 75 functions (exceeds 20 allowed). Consider refactoring.
Open

class StateMachineImpl implements StateMachine
{
    use AssertTrait;
    use EventHandlerTrait;

Severity: Major
Found in src/Imp/StateMachineImpl.php - About 1 day to fix

    File StateMachineImpl.php has 595 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    namespace Pluf\Workflow\Imp;
    
    use Pluf\Workflow\ActionExecutionService;
    use Pluf\Workflow\ErrorCodes;
    Severity: Major
    Found in src/Imp/StateMachineImpl.php - About 1 day to fix

      Method processEvent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function processEvent($event, $context, StateMachineData $originalData, ExecutionServiceImpl $executionService, bool $DataIsolateEnabled): bool
          {
              $localData = $originalData;
              $fromState = $localData->read()->getCurrentRawState();
              $fromStateId = $fromState->getStateId();
      Severity: Minor
      Found in src/Imp/StateMachineImpl.php - About 1 hr to fix

        Method internalTest has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function internalTest($event, $context)
            {
                $this->checkState($this->status != 'ERROR' && $this->status != 'TERMINATED', "Cannot test state machine under " . $this->status . " status.");
        
                $testResult = null;
        Severity: Minor
        Found in src/Imp/StateMachineImpl.php - About 1 hr to fix

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

              private function internalTest($event, $context)
              {
                  $this->checkState($this->status != 'ERROR' && $this->status != 'TERMINATED', "Cannot test state machine under " . $this->status . " status.");
          
                  $testResult = null;
          Severity: Minor
          Found in src/Imp/StateMachineImpl.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 processEvents has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private function processEvents(): void
              {
                  if ($this->isIdle()) {
                      $this->setStatus('BUSY');
                      try {
          Severity: Minor
          Found in src/Imp/StateMachineImpl.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

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

              public function fireEvent($event, $context = null, bool $insertAtFirst = false): self
              {
                  $isEntryPoint = $this->isEntryPoint();
                  if ($isEntryPoint) {
                      StateMachineContext::set($this);
          Severity: Minor
          Found in src/Imp/StateMachineImpl.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

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

              private function internalFire($event, $context, bool $insertAtFirst = false): void
              {
                  if ($this->getStatus() == 'INITIALIZED') {
                      if ($this->autoStartEnabled) {
                          $this->start($context);
          Severity: Minor
          Found in src/Imp/StateMachineImpl.php - About 45 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 processEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function processEvent($event, $context, StateMachineData $originalData, ExecutionServiceImpl $executionService, bool $DataIsolateEnabled): bool
          Severity: Minor
          Found in src/Imp/StateMachineImpl.php - About 35 mins to fix

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

                private function processEvent($event, $context, StateMachineData $originalData, ExecutionServiceImpl $executionService, bool $DataIsolateEnabled): bool
                {
                    $localData = $originalData;
                    $fromState = $localData->read()->getCurrentRawState();
                    $fromStateId = $fromState->getStateId();
            Severity: Minor
            Found in src/Imp/StateMachineImpl.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

            There are no issues that match your filters.

            Category
            Status