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\ComplexityCode
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;
}