forked from babenkoivan/scout-elasticsearch-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHighlight.php
43 lines (37 loc) · 760 Bytes
/
Highlight.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace ScoutElastic;
class Highlight
{
/**
* The highlight array.
*
* @var array
*/
private $highlight;
/**
* Highlight constructor.
*
* @param array $highlight
* @return void
*/
public function __construct(array $highlight)
{
$this->highlight = $highlight;
}
/**
* Get a value.
*
* @param string $key
* @return mixed|string|null
*/
public function __get($key)
{
$field = str_replace('AsString', '', $key);
if (isset($this->highlight[$field])) {
$value = $this->highlight[$field];
return $field == $key ? $value : implode(' ', $value);
} else {
return;
}
}
}