Traverser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 29
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A traverse() 0 6 1
A traverseNode() 0 12 3
1
<?php
2
3
namespace HansOtt\GraphQL\Query;
4
5
final class Traverser
6
{
7
    private $visitor;
8
9 3
    public function __construct(Visitor $visitor)
10
    {
11 3
        $this->visitor = $visitor;
12 3
    }
13
14 3
    public function traverse(Document $document)
15
    {
16 3
        $this->visitor->beforeTraverse($document);
17 3
        $this->traverseNode($document);
18 3
        $this->visitor->afterTraverse($document);
19 3
    }
20
21 3
    private function traverseNode(Node $node)
22
    {
23 3
        $this->visitor->enterNode($node);
24 3
        $children = $node->getChildren();
25 3
        foreach ($children as $child) {
26 3
            if ($child instanceof Node) {
27 3
                $this->traverseNode($child);
28 3
            }
29 3
        }
30
31 3
        $this->visitor->leaveNode($node);
32 3
    }
33
}
34