Inflate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 3
1
<?php
2
3
namespace Vine\Commands;
4
5
use Vine\NodeCollection;
6
7
class Inflate
8
{
9
    /**
10
     * Return proper tree structure of flattened node collection.
11
     * Nodes from a flat collection retain their relations so
12
     * we just need to return the root nodes
13
     *
14
     * @param NodeCollection $flatCollection
15
     * @return NodeCollection
16
     */
17 6
    public function __invoke(NodeCollection $flatCollection): NodeCollection
18
    {
19 6
        $roots = new NodeCollection();
20
21 6
        foreach($flatCollection as $k => $node)
22
        {
23 6
            if($node->isRoot())
24
            {
25 6
                $roots->add($node);
26
            }
27
        }
28
29 6
        return $roots;
30
    }
31
}
32