Completed
Pull Request — master (#52)
by Daniel
09:53
created

NamedQueryCriteriaCollection   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 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 49
ccs 12
cts 12
cp 1
rs 10

4 Methods

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