ResultCollection::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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