NodesBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 16 3
1
<?php
2
3
namespace Knp\FriendlyContexts\Table;
4
5
use Knp\FriendlyContexts\Table\Node;
6
use Knp\FriendlyContexts\Table\NodeCollection;
7
8
class NodesBuilder
9
{
10
    public function build(array $table)
11
    {
12
        $collection = new NodeCollection;
13
        foreach ($table as $line => $columns) {
14
            foreach ($columns as $column => $content) {
15
                $collection->addNode($node = new Node, $line, $column);
16
                $node->setContent($content);
17
                $node->setTop($collection->atPosition($line - 1, $column));
18
                $node->setBottom($collection->atPosition($line + 1, $column));
19
                $node->setLeft($collection->atPosition($line, $column - 1));
20
                $node->setLeft($collection->atPosition($line, $column + 1));
21
            }
22
        }
23
24
        return $collection;
25
    }
26
}
27