Completed
Pull Request — master (#21)
by Daniel
02:31
created

Body   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A current() 0 8 1
A next() 0 4 1
A key() 0 4 1
A rewind() 0 4 1
A valid() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Grid\View;
6
7
use Psi\Component\Grid\Metadata\GridMetadata;
8
use Psi\Component\Grid\CellFactory;
9
10
class Body implements \Iterator
11
{
12
    private $cellFactory;
13
    private $gridMetadata;
14
    private $collection;
15
16
    public function __construct(
17
        CellFactory $cellFactory,
18
        GridMetadata $gridMetadata,
19
        \Iterator $collection
20
    ) {
21
        $this->cellFactory = $cellFactory;
22
        $this->gridMetadata = $gridMetadata;
23
        $this->collection = $collection;
24
    }
25
26
    public function current()
27
    {
28
        return new Row(
29
            $this->cellFactory,
30
            $this->gridMetadata,
31
            $this->collection->current()
32
        );
33
    }
34
35
    public function next()
36
    {
37
        return $this->collection->next();
38
    }
39
40
    public function key()
41
    {
42
        return $this->collection->key();
43
    }
44
45
    public function rewind()
46
    {
47
        return $this->collection->rewind();
48
    }
49
50
    public function valid()
51
    {
52
        return $this->collection->valid() ? true : false;
53
    }
54
}
55