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

Table::getHeaders()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 0
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