SearchEvent::addResult()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace SumoCoders\FrameworkSearchBundle\Event;
4
5
use SumoCoders\FrameworkSearchBundle\Entity\SearchResult;
6
use Symfony\Component\EventDispatcher\Event;
7
8
class SearchEvent extends Event
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $foundItems = array();
14
15
    /**
16
     * @var array
17
     */
18
    protected $results = array();
19
20
    /**
21
     * @param array $foundItems
22
     */
23 4
    public function setFoundItems(array $foundItems)
24
    {
25 4
        $this->foundItems = $foundItems;
26 4
    }
27
28
    /**
29
     * @return mixed
30
     */
31
    public function getFoundItems()
32
    {
33
        return $this->foundItems;
34
    }
35
36
    /**
37
     * @param string $class
38
     * @return array
39
     */
40
    public function getFoundIdsForClass($class)
41
    {
42
        if (!array_key_exists($class, $this->foundItems)) {
43
            return array();
44
        }
45
46
        return $this->foundItems[$class];
47
    }
48
49
    /**
50
     * @param SearchResult $result
51
     */
52 3
    public function addResult(SearchResult $result)
53
    {
54 3
        $class = $result->getClass();
55 3
        $id = $result->getId();
56
57 3
        $this->results[$class][$id] = $result;
58 3
    }
59
60
    /**
61
     * @return array
62
     */
63 4
    public function getResults()
64
    {
65 4
        return $this->results;
66
    }
67
}
68