Row   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 4 1
A current() 0 11 1
A next() 0 4 1
A key() 0 4 1
A rewind() 0 4 1
A valid() 0 4 1
A __construct() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Grid\View;
6
7
use Psi\Component\Grid\ColumnFactory;
8
use Psi\Component\Grid\GridContext;
9
use Psi\Component\Grid\Metadata\GridMetadata;
10
11
class Row implements \Iterator
12
{
13
    private $columnFactory;
14
    private $columnMetadatas;
15
    private $data;
16
17
    public function __construct(
18
        ColumnFactory $columnFactory,
19
        GridMetadata $gridMetadata,
20
        GridContext $gridContext,
21
        $data
22
    ) {
23
        $this->columnFactory = $columnFactory;
24
        $this->columnMetadatas = $gridMetadata->getColumnsForGroups($gridContext->getGroups());
25
        $this->data = $data;
26
    }
27
28
    public function getData()
29
    {
30
        return $this->data;
31
    }
32
33
    public function current(): Cell
34
    {
35
        $columnMetadata = current($this->columnMetadatas);
36
37
        return $this->columnFactory->createCell(
38
            $this->key(),
39
            $columnMetadata->getType(),
40
            $this->data,
41
            $columnMetadata->getOptions()
42
        );
43
    }
44
45
    public function next()
46
    {
47
        return next($this->columnMetadatas);
48
    }
49
50
    public function key()
51
    {
52
        return key($this->columnMetadatas);
53
    }
54
55
    public function rewind()
56
    {
57
        return reset($this->columnMetadatas);
58
    }
59
60
    public function valid()
61
    {
62
        return current($this->columnMetadatas) !== false;
63
    }
64
}
65