-
Notifications
You must be signed in to change notification settings - Fork 1
/
AElasticSearchResponse.php
executable file
·48 lines (41 loc) · 1.2 KB
/
AElasticSearchResponse.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
44
45
46
47
48
<?php
/**
* Holds a response from elastic search
* @author Charles Pick
* @author Stratos Gerakakis
* @package packages.elasticSearch
*/
class AElasticSearchResponse extends CAttributeCollection {
/**
* @var boolean whether the keys are case-sensitive. Defaults to false.
*/
public $caseSensitive = true;
/**
* Adds an item into the map.
* If the item is an array, it will be converted to an instance of AElasticSearchResponse
*
* @param mixed $key key
* @param mixed $value value
*/
public function add($key, $value) {
if (is_array($value) && count($value)) {
//$s = array_shift(array_keys($value));
//if( is_string(array_shift(array_keys($value))))
$value = new AElasticSearchResponse($value);
}
parent::add($key, $value);
}
/**
* @return array the list of items in array
*/
public function toArray() {
$data = array();
foreach (parent::toArray() as $key => $value) {
if ($value instanceof AElasticSearchResponse) {
$value = $value->toArray();
}
$data[$key] = $value;
}
return $data;
}
}