Completed
Push — master-4.0 ( 71618b...2eaeb5 )
by Krzysztof
03:06 queued 03:01
created

ResultCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 34
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
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 6
    public function addNamedItem($name, $item)
22
    {
23 6
        return parent::addNamedItem($name, $item);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 10
    public function getResults()
30
    {
31 10
        return $this->getItems();
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 5
    public function jsonSerialize()
38
    {
39 5
        return $this->getItems();
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45 10
    protected function isItemValid($item)
46
    {
47 10
        return true;
48
    }
49
}
50