SearchEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 2
dl 0
loc 60
ccs 10
cts 16
cp 0.625
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setFoundItems() 0 4 1
A getFoundItems() 0 4 1
A getFoundIdsForClass() 0 8 2
A addResult() 0 7 1
A getResults() 0 4 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