Code Duplication    Length = 20-21 lines in 2 locations

src/Hal/Metric/System/Coupling/Coupling.php 1 location

@@ 27-46 (lines=20) @@
24
        // build a graph of relations
25
        $graph = new Graph();
26
27
        foreach ($metrics->all() as $metric) {
28
            if (!$metric instanceof ClassMetric) {
29
                continue;
30
            }
31
32
            if (!$graph->has($metric->get('name'))) {
33
                $graph->insert(new Node($metric->get('name')));
34
            }
35
            $from = $graph->get($metric->get('name'));
36
37
            foreach ($metric->get('externals') as $external) {
38
                if (!$graph->has($external)) {
39
                    $graph->insert(new Node($external));
40
                }
41
42
                $to = $graph->get($external);
43
44
                $graph->addEdge($from, $to);
45
            }
46
        }
47
48
        // analyze relations
49
        foreach ($metrics->all() as $metric) {

src/Hal/Metric/System/Coupling/DepthOfInheritanceTree.php 1 location

@@ 32-52 (lines=21) @@
29
        // building graph with parents / childs relations only
30
        $graph = new Graph();
31
32
        foreach ($metrics->all() as $metric) {
33
            if (!$metric instanceof ClassMetric) {
34
                continue;
35
            }
36
37
            if (!$graph->has($metric->get('name'))) {
38
                $graph->insert(new Node($metric->get('name')));
39
            }
40
41
            $to = $graph->get($metric->get('name'));
42
43
            foreach ($metric->get('parents') as $parent) {
44
                if (!$graph->has($parent)) {
45
                    $graph->insert(new Node($parent));
46
                }
47
48
                $from = $graph->get($parent);
49
50
                $graph->addEdge($from, $to);
51
            }
52
        }
53
54
        $size = new SizeOfTree($graph);
55
        $averageHeight = $size->getAverageHeightOfGraph();