Completed
Push — master ( 9291df...2cfea9 )
by Peter
02:39
created

Rows   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 59
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A offsetSet() 0 6 1
A current() 0 9 1
A offsetGet() 0 9 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Foo\Grid\Collection;
6
7
use Foo\Grid\Row\IRow;
8
use InvalidArgumentException;
9
use LogicException;
10
11
class Rows extends BaseCollection
12
{
13
    /** @var IRow[] */
14
    protected $components = [];
15
16
    /**
17
     * @param string|null $tag
18
     * @param array       $attributes
19
     */
20 10
    public function __construct(string $tag = null, $attributes = [])
21
    {
22 10
        $tag = $tag ?: 'tbody';
23
24 10
        parent::__construct($tag, $attributes);
25 10
    }
26
27
    /**
28
     * @return IRow
29
     * @throws LogicException
30
     */
31 5
    public function current()
32
    {
33
        /** @var IRow $object */
34 5
        $object = parent::current();
35
36 5
        $this->verifyReturn($object, IRow::class);
37
38 5
        return $object;
39
    }
40
41
    /**
42
     * @param int|null $offset
43
     * @param IRow     $value
44
     *
45
     * @throws InvalidArgumentException
46
     */
47 10
    public function offsetSet($offset, $value)
48
    {
49 10
        $this->verifyArgument($value, IRow::class);
50
51 9
        parent::offsetSet($offset, $value);
52 9
    }
53
54
    /**
55
     * @param int $offset
56
     *
57
     * @return IRow|null
58
     * @throws LogicException
59
     */
60 1
    public function offsetGet($offset)
61
    {
62
        /** @var IRow $object */
63 1
        $object = parent::offsetGet($offset);
64
65 1
        $this->verifyReturn($object, IRow::class);
66
67 1
        return $object;
68
    }
69
}
70