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

ResultCollection::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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