RewriteArray   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 39
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A current() 0 4 1
A add() 0 6 1
A set() 0 6 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