Completed
Push — master ( 406296...0a0b96 )
by Daniel
07:00 queued 04:29
created

Table   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getHeaders() 0 9 2
A getBody() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Grid\View;
6
7
use Psi\Component\Grid\CellFactory;
8
use Psi\Component\Grid\GridContext;
9
use Psi\Component\Grid\Metadata\GridMetadata;
10
11
class Table
12
{
13
    private $cellFactory;
14
    private $gridMetadata;
15
    private $collection;
16
    private $context;
17
18
    public function __construct(
19
        CellFactory $cellFactory,
20
        GridMetadata $gridMetadata,
21
        \Iterator $collection,
22
        GridContext $context
23
    ) {
24
        $this->cellFactory = $cellFactory;
25
        $this->gridMetadata = $gridMetadata;
26
        $this->collection = $collection;
27
        $this->context = $context;
28
    }
29
30
    public function getHeaders()
31
    {
32
        $headers = [];
33
        foreach (array_keys($this->gridMetadata->getColumns()) as $headerName) {
34
            $headers[$headerName] = new Header($headerName, $this->context);
35
        }
36
37
        return $headers;
38
    }
39
40
    public function getBody()
41
    {
42
        return new Body(
43
            $this->cellFactory,
44
            $this->gridMetadata,
45
            $this->collection
46
        );
47
    }
48
}
49