Completed
Push — master ( 7a35bc...7eff79 )
by Krzysztof
05:49 queued 02:58
created

NamedCriteriaCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 49
rs 10
ccs 12
cts 12
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 4 1
A __set() 0 4 1
A addNamedCriteria() 0 8 1
A getNamedCriteria() 0 6 2
1
<?php
2
3
namespace KGzocha\Searcher\Criteria\Collection;
4
5
use KGzocha\Searcher\Criteria\CriteriaInterface;
6
7
/**
8
 * @author Krzysztof Gzocha <[email protected]>
9
 */
10
class NamedCriteriaCollection extends CriteriaCollection implements
11
    NamedCriteriaCollectionInterface
12
{
13
    /**
14
     * @param string $name
15
     *
16
     * @return null|CriteriaInterface
17
     */
18 1
    public function __get($name)
19
    {
20 1
        return $this->getNamedCriteria($name);
21
    }
22
23
    /**
24
     * @param string                 $name
25
     * @param CriteriaInterface $value
26
     */
27 1
    public function __set($name, CriteriaInterface $value)
28
    {
29 1
        $this->addNamedCriteria($name, $value);
30 1
    }
31
32
    /**
33
     * @param string                 $name
34
     * @param CriteriaInterface $filterModel
35
     *
36
     * @return $this
37
     */
38 2
    public function addNamedCriteria(
39
        $name,
40
        CriteriaInterface $filterModel
41
    ) {
42 2
        $this->criteria[$name] = $filterModel;
43
44 2
        return $this;
45
    }
46
47
    /**
48
     * @param string $name
49
     *
50
     * @return null|CriteriaInterface
51
     */
52 1
    public function getNamedCriteria($name)
53
    {
54 1
        return array_key_exists($name, $this->criteria)
55 1
            ? $this->criteria[$name]
56 1
            : null;
57
    }
58
}
59