RewriteArray::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * File: RewriteArray.php
4
 *
5
 * @author Maciej Sławik <[email protected]>
6
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
7
 */
8
declare(strict_types=1);
9
10
namespace LizardMedia\GoogleAnalyticsVerifier\Model\Data;
11
12
use LizardMedia\GoogleAnalyticsVerifier\Api\Data\RewriteInterface;
13
14
/**
15
 * Class RewriteArray
16
 * @package LizardMedia\GoogleAnalyticsVerifier\Model\Data
17
 */
18
class RewriteArray extends \IteratorIterator
19
{
20
    /**
21
     * RewriteArray constructor.
22
     */
23
    public function __construct()
24
    {
25
        parent::__construct(new \ArrayIterator());
26
    }
27
28
    /**
29
     * @return RewriteInterface
30
     */
31
    public function current(): RewriteInterface
32
    {
33
        return parent::current();
34
    }
35
36
    /**
37
     * @param RewriteInterface $rewrite
38
     */
39
    public function add(RewriteInterface $rewrite)
40
    {
41
        $arrayIterator = $this->getInnerIterator();
42
        /** @var $arrayIterator \ArrayIterator */
43
        $arrayIterator->append($rewrite);
44
    }
45
46
    /**
47
     * @param int $key
48
     * @param RewriteInterface $rewrite
49
     */
50
    public function set(int $key, RewriteInterface $rewrite)
51
    {
52
        $arrayIterator = $this->getInnerIterator();
53
        /** @var $arrayIterator \ArrayIterator */
54
        $arrayIterator->offsetSet($key, $rewrite);
55
    }
56
}
57