Completed
Push — abstract-collection ( 5120af...458de3 )
by Krzysztof
04:53
created

ResultCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 4 1
A addNamedItem() 0 4 1
A getResults() 0 4 1
A jsonSerialize() 0 4 1
A isItemValid() 0 4 1
1
<?php
2
3
namespace KGzocha\Searcher\Result;
4
5
use KGzocha\Searcher\AbstractCollection;
6
7
/**
8
 * Can be used to hold results from searching when developer is not 100% sure
9
 * if searching process will return array of objects or a number, or null, or whatever.
10
 * This class regardless the constructor will always be iteratable, so in worse case scenario
11
 * there will be no results inside, but your controllers will still work.
12
 * It's not recommended to use it on development environment due to eventual problems with debugging.
13
 *
14
 * @author Krzysztof Gzocha <[email protected]>
15
 */
16
class ResultCollection extends AbstractCollection implements ResultCollectionInterface
17
{
18
    /**
19
     * @inheritDoc
20
     */
21 1
    public function addItem($item)
22
    {
23 1
        return parent::addItem($item);
24
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29 3
    public function addNamedItem($name, $item)
30
    {
31 3
        return parent::addNamedItem($name, $item);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 10
    public function getResults()
38
    {
39 10
        return $this->getItems();
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 5
    public function jsonSerialize()
46
    {
47 5
        return $this->getItems();
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53 10
    protected function isItemValid($item)
54
    {
55 10
        return true;
56
    }
57
}
58