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

Breadcrumb

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

class CyclomaticComplexityCalculatingVisitor

Hierarchy

  • class \PhpParser\NodeVisitorAbstract implements \PhpParser\NodeVisitor
    • class \SebastianBergmann\Complexity\CyclomaticComplexityCalculatingVisitor extends \PhpParser\NodeVisitorAbstract

Expanded class hierarchy of CyclomaticComplexityCalculatingVisitor

1 file declares its use of CyclomaticComplexityCalculatingVisitor
CodeUnitFindingVisitor.php in vendor/phpunit/php-code-coverage/src/StaticAnalysis/CodeUnitFindingVisitor.php

File

vendor/sebastian/complexity/src/Visitor/CyclomaticComplexityCalculatingVisitor.php, line 27

Namespace

SebastianBergmann\Complexity
View source
final class CyclomaticComplexityCalculatingVisitor extends NodeVisitorAbstract {
    
    /**
     * @psalm-var positive-int
     */
    private int $cyclomaticComplexity = 1;
    public function enterNode(Node $node) : void {
        switch ($node::class) {
            case BooleanAnd::class:
            case BooleanOr::class:
            case Case_::class:
            case Catch_::class:
            case ElseIf_::class:
            case For_::class:
            case Foreach_::class:
            case If_::class:
            case LogicalAnd::class:
            case LogicalOr::class:
            case Ternary::class:
            case While_::class:
                $this->cyclomaticComplexity++;
        }
    }
    
    /**
     * @psalm-return positive-int
     */
    public function cyclomaticComplexity() : int {
        return $this->cyclomaticComplexity;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
CyclomaticComplexityCalculatingVisitor::$cyclomaticComplexity private property @psalm-var positive-int
CyclomaticComplexityCalculatingVisitor::cyclomaticComplexity public function @psalm-return positive-int
CyclomaticComplexityCalculatingVisitor::enterNode public function Called when entering a node. Overrides NodeVisitorAbstract::enterNode
NodeVisitor::DONT_TRAVERSE_CHILDREN public constant If NodeVisitor::enterNode() returns DONT_TRAVERSE_CHILDREN, child nodes
of the current node will not be traversed for any visitors.
NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN public constant If NodeVisitor::enterNode() returns DONT_TRAVERSE_CURRENT_AND_CHILDREN, child nodes
of the current node will not be traversed for any visitors.
NodeVisitor::REMOVE_NODE public constant If NodeVisitor::leaveNode() returns REMOVE_NODE for a node that occurs
in an array, it will be removed from the array.
NodeVisitor::REPLACE_WITH_NULL public constant If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns REPLACE_WITH_NULL,
the node will be replaced with null. This is not a legal return value if the node is part
of an array, rather than another node.
NodeVisitor::STOP_TRAVERSAL public constant If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns
STOP_TRAVERSAL, traversal is aborted.
NodeVisitorAbstract::afterTraverse public function Called once after traversal. Overrides NodeVisitor::afterTraverse 1
NodeVisitorAbstract::beforeTraverse public function Called once before traversal. Overrides NodeVisitor::beforeTraverse 5
NodeVisitorAbstract::leaveNode public function Called when leaving a node. Overrides NodeVisitor::leaveNode 2

API Navigation

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