Code Duplication    Length = 13-14 lines in 2 locations

phpmetrics/src/Hal/Metric/Class_/Structural/LcomVisitor.php 2 locations

@@ 61-73 (lines=13) @@
58
                    }
59
60
                    \iterate_over_node($stmt, function ($node) use ($from, &$graph) {
61
                        if ($node instanceof Node\Expr\PropertyFetch && isset($node->var->name) && $node->var->name == 'this') {
62
                            $name = (string)getNameOfNode($node);
63
                            // use of attribute $this->xxx;
64
                            if (!$graph->has($name)) {
65
                                $graph->insert(new TreeNode($name));
66
                            }
67
                            $to = $graph->get($name);
68
                            if ($to === null) {
69
                                throw new ShouldNotHappenException('Graph $to is null');
70
                            }
71
                            $graph->addEdge($from, $to);
72
                            return;
73
                        }
74
75
                        if ($node instanceof Node\Expr\MethodCall) {
76
                            if (!$node->var instanceof Node\Expr\New_ && isset($node->var->name) && getNameOfNode($node->var) === 'this') {
@@ 76-89 (lines=14) @@
73
                        }
74
75
                        if ($node instanceof Node\Expr\MethodCall) {
76
                            if (!$node->var instanceof Node\Expr\New_ && isset($node->var->name) && getNameOfNode($node->var) === 'this') {
77
                                // use of method call $this->xxx();
78
                                // use of attribute $this->xxx;
79
                                $name = getNameOfNode($node->name) . '()';
80
                                if (!$graph->has($name)) {
81
                                    $graph->insert(new TreeNode($name));
82
                                }
83
                                $to = $graph->get($name);
84
                                if ($to === null) {
85
                                    throw new ShouldNotHappenException('Graph $to is null');
86
                                }
87
                                $graph->addEdge($from, $to);
88
                                return;
89
                            }
90
                        }
91
                    });
92
                }