-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDocument.php
More file actions
90 lines (67 loc) · 1.21 KB
/
Document.php
File metadata and controls
90 lines (67 loc) · 1.21 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php declare(strict_types = 1);
namespace Spameri\ElasticQuery;
class Document implements \Spameri\ElasticQuery\Entity\ArrayInterface
{
/**
* @var ?string
*/
private $index;
/**
* @var ?\Spameri\ElasticQuery\Document\BodyInterface
*/
private $body;
/**
* @var ?string
*/
private $type;
/**
* @var ?string
*/
private $id;
/**
* @var array
*/
private $options;
public function __construct(
?string $index
, ?\Spameri\ElasticQuery\Document\BodyInterface $body = NULL
, ?string $type = NULL
, ?string $id = NULL
, array $options = []
)
{
$this->index = $index;
$this->body = $body;
$this->type = $type;
$this->id = $id;
$this->options = $options;
}
public function index(): ?string
{
return $this->index;
}
public function type(): ?string
{
return $this->type;
}
public function toArray(): array
{
$array = [];
if ($this->index) {
$array['index'] = $this->index;
}
if ($this->body) {
$array['body'] = $this->body->toArray();
}
if ($this->type) {
$array['type'] = $this->type;
}
if ($this->id) {
$array['id'] = $this->id;
}
if ($this->options) {
$array = \array_merge($array, $this->options);
}
return $array;
}
}