Result   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 29
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addFieldResult() 0 3 1
A getResultsByField() 0 9 2
1
<?php
2
3
namespace Mdiyakov\DoctrineSolrBundle\Query\Suggest\Result;
4
5
use Mdiyakov\DoctrineSolrBundle\Exception\SuggestResultException;
6
7
class Result
8
{
9
    /**
10
     * @var FieldResult[]
11
     */
12
    private $data;
13
14
    /**
15
     * @param FieldResult $fieldResult
16
     */
17
    public function addFieldResult(FieldResult $fieldResult)
18
    {
19
        $this->data[$fieldResult->getEntityFieldName()] = $fieldResult;
20
    }
21
22
    /**
23
     * @param $entityFieldName
24
     * @return FieldResult
25
     * @throws SuggestResultException
26
     */
27
    public function getResultsByField($entityFieldName)
28
    {
29
        if (!array_key_exists($entityFieldName, $this->data)) {
30
            throw new SuggestResultException(
31
                sprintf('There is no result for %s entity field', $entityFieldName)
32
            );
33
        }
34
35
        return $this->data[$entityFieldName];
36
    }
37
}