Completed
Push — master ( 5ebe79...868b20 )
by Owen
01:17
created

MutableKeyedCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 5 1
A removeByKey() 0 7 2
1
<?php
2
3
namespace Mundanity\Collection;
4
5
6
/**
7
 * A mutable keyed collection.
8
 *
9
 */
10
class MutableKeyedCollection extends KeyedCollection implements MutableKeyedCollectionInterface
11
{
12
    use MutableTrait;
13
14
    /**
15
     * {@inheritdoc}
16
     *
17
     */
18
    public function add($key, $item)
19
    {
20
        $this->data[$key] = $item;
21
        return $this;
22
    }
23
24
25
    /**
26
     * {@inheritdoc}
27
     *
28
     */
29
    public function removeByKey($key)
30
    {
31
        if (array_key_exists($key, $this->data)) {
32
            unset($this->data[$key]);
33
        }
34
        return $this;
35
    }
36
}
37