Actions::offsetGet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Foo\Grid\Collection;
6
7
use Foo\Grid\Action\IAction;
8
use InvalidArgumentException;
9
use LogicException;
10
11
class Actions extends BaseCollection
12
{
13
    /** @var IAction[] */
14
    protected $components = [];
15
16
    /**
17
     * @return IAction
18
     * @throws LogicException
19
     */
20 5
    public function current()
21
    {
22
        /** @var IAction $object */
23 5
        $object = parent::current();
24
25 5
        $this->verifyReturn($object, IAction::class);
26
27 5
        return $object;
28
    }
29
30
    /**
31
     * @param int|null $offset
32
     * @param IAction  $value
33
     *
34
     * @throws InvalidArgumentException
35
     */
36 15
    public function offsetSet($offset, $value)
37
    {
38 15
        $this->verifyArgument($value, IAction::class);
39
40 14
        parent::offsetSet($offset, $value);
41 14
    }
42
43
    /**
44
     * @param int $offset
45
     *
46
     * @return IAction|null
47
     * @throws LogicException
48
     */
49 1
    public function offsetGet($offset)
50
    {
51
        /** @var IAction $object */
52 1
        $object = parent::offsetGet($offset);
53
54 1
        $this->verifyReturn($object, IAction::class);
55
56 1
        return $object;
57
    }
58
59
    /**
60
     * @return Actions
61
     */
62 1
    public function duplicate(): Actions
63
    {
64 1
        $actionsCopy = new Actions($this->tag, $this->attributes);
65
66 1
        foreach ($this->components as $action) {
67
            $actionCopy    = $action->duplicate();
68
            $actionsCopy[] = $actionCopy;
69
        }
70
71 1
        return $actionsCopy;
72
    }
73
74
}
75