Completed
Branch master (0e0537)
by Krzysztof
02:41
created

ResultCollection::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A ResultCollection::getResults() 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