SitemapFilterEvent::offsetUnset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
namespace Zicht\Bundle\UrlBundle\Event;
6
7
use Symfony\Component\EventDispatcher\Event;
8
9
class SitemapFilterEvent extends Event implements \ArrayAccess, \IteratorAggregate, \Countable
10
{
11
    /** @var \ArrayObject */
12
    protected $object;
13
14
    /**
15
     * SitemapFilterEvent constructor.
16
     *
17
     * @param \ArrayObject $object
18
     */
19
    public function __construct(\ArrayObject $object)
20
    {
21
        $this->object = $object;
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function getArrayCopy()
28
    {
29
        return $this->object->getArrayCopy();
30
    }
31
32
    /**
33
     * @param callable $filter
34
     */
35
    public function filter(callable $filter)
36
    {
37
        foreach ($this->object as $key => $value) {
38
            if (false === $filter($key, $value)) {
39
                $this->offsetUnset($key);
40
            }
41
        }
42
    }
43
44
    /**
45
     * @param array $data
46
     * @return array
47
     */
48
    public function exchange(array $data)
49
    {
50
        return $this->object->exchangeArray($data);
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function offsetExists($offset)
57
    {
58
        return $this->object->offsetExists($offset);
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function offsetGet($offset)
65
    {
66
        return $this->object->offsetGet($offset);
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function offsetSet($offset, $value)
73
    {
74
        $this->object->offsetSet($offset, $value);
75
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80
    public function offsetUnset($offset)
81
    {
82
        $this->object->offsetUnset($offset);
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function getIterator()
89
    {
90
        foreach ($this->object as $key => $value) {
91
            yield $key => $value;
92
        }
93
    }
94
95
    /**
96
     * @inheritdoc
97
     */
98
    public function count()
99
    {
100
        return $this->object->count();
101
    }
102
}
103