Completed
Push — master ( 734525...97c065 )
by Owen
02:29
created

KeyedCollection::hasKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Mundanity\Collection;
4
5
6
/**
7
 * A keyed collection.
8
 *
9
 */
10
class KeyedCollection extends Collection implements KeyedCollectionInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     *
15
     */
16
    public function hasKey($key)
17
    {
18
        return array_key_exists($key, $this->data);
19
    }
20
21
22
    /**
23
     * {@inheritdoc}
24
     *
25
     */
26
    public function getByKey($key)
27
    {
28
        if ($this->hasKey($key)) {
29
            return is_object($this->data[$key]) ? clone $this->data[$key] : $this->data[$key];
30
        }
31
    }
32
}
33