Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CognitiveSniff.php

function CognitiveSniff::resolveBooleanOperatorChain

* Keep track of consecutive matching boolean operators, that don't receive increment. * *

Parameters

array{code:int|string} $token:

1 call to CognitiveSniff::resolveBooleanOperatorChain()
CognitiveSniff::computeForFunctionFromTokensAndPosition in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Complexity/CognitiveSniff.php

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Complexity/CognitiveSniff.php, line 258

Class

CognitiveSniff
Cognitive Complexity

Namespace

SlevomatCodingStandard\Sniffs\Complexity

Code

private function resolveBooleanOperatorChain(array $token) : void {
    $code = $token['code'];
    // Whenever we cross anything that interrupts possible condition we reset chain.
    if ($this->lastBooleanOperator > 0 && isset(self::OPERATOR_CHAIN_BREAKS[$code])) {
        $this->lastBooleanOperator = 0;
        return;
    }
    if (isset(self::BOOLEAN_OPERATORS[$code]) === false) {
        return;
    }
    // If we match last operator, there is no increment added for current one.
    if ($this->lastBooleanOperator === $code) {
        return;
    }
    $this->cognitiveComplexity++;
    $this->lastBooleanOperator = $code;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal