| Conditions | 4 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function search($term) |
||
| 16 | { |
||
| 17 | $query = $this->createQueryBuilder('r') |
||
| 18 | ->where('r.value LIKE :term') |
||
| 19 | ->setParameter('term', '%' . $term . '%') |
||
| 20 | ->getQuery(); |
||
| 21 | |||
| 22 | $results = $query->getResult(); |
||
| 23 | |||
| 24 | if (empty($results)) { |
||
| 25 | return null; |
||
| 26 | } |
||
| 27 | |||
| 28 | // group per class |
||
| 29 | $items = array(); |
||
| 30 | foreach ($results as $indexItem) { |
||
| 31 | /** @var $indexItem IndexItem */ |
||
| 32 | $class = $indexItem->getObjectType(); |
||
| 33 | $id = $indexItem->getOtherId(); |
||
| 34 | |||
| 35 | if (!isset($items[$class][$id])) { |
||
| 36 | $items[$class][$id] = 0; |
||
| 37 | } |
||
| 38 | |||
| 39 | $items[$class][$id]++; |
||
| 40 | } |
||
| 41 | |||
| 42 | return $items; |
||
| 43 | } |
||
| 44 | } |
||
| 45 |