ResultHit   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 57
rs 10
wmc 12

10 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A __construct() 0 3 1
A getData() 0 3 1
A get() 0 6 2
A __isset() 0 3 2
A __get() 0 3 1
A setId() 0 3 1
A getScore() 0 3 1
A getHighlight() 0 3 1
A getId() 0 3 1
1
<?php
2
3
4
namespace Manticoresearch;
5
6
/**
7
 * Result hit object
8
 * Element of a result set
9
 * @category ManticoreSearch
10
 * @package ManticoreSearch
11
 * @author Adrian Nuta <[email protected]>
12
 * @link https://manticoresearch.com
13
 */
14
class ResultHit
15
{
16
    protected $data;
17
18
    public function __construct($data = [])
19
    {
20
        $this->data = $data;
21
    }
22
23
    public function getId()
24
    {
25
        return $this->data['_id'];
26
    }
27
28
    public function setId($id)
29
    {
30
        $this->data['_id'] = $id;
31
    }
32
33
    public function getScore()
34
    {
35
        return $this->data['_score'];
36
    }
37
38
    public function getHighlight()
39
    {
40
        return $this->data['highlight'];
41
    }
42
43
44
    public function __get(string $key)
45
    {
46
        return $this->get($key);
47
    }
48
49
    public function __isset(string $key): bool
50
    {
51
        return $this->has($key) && null !== $this->get($key);
52
    }
53
54
    public function get($key)
55
    {
56
        if (isset($this->data['_source'][$key])) {
57
            return $this->data['_source'][$key];
58
        }
59
        return [];
60
    }
61
62
63
    public function has($key)
64
    {
65
        return isset($this->data['_source'][$key]);
66
    }
67
68
    public function getData()
69
    {
70
        return $this->data['_source'];
71
    }
72
}
73