1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AmaTeam\ElasticSearch\API\Entity\Indexing; |
6
|
|
|
|
7
|
|
|
class Indexing implements IndexingInterface |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var string[] |
11
|
|
|
*/ |
12
|
|
|
private $readIndices = []; |
13
|
|
|
/** |
14
|
|
|
* @var string[] |
15
|
|
|
*/ |
16
|
|
|
private $writeIndices = []; |
17
|
|
|
/** |
18
|
|
|
* TODO: move default value somewhere |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $type = 'doc'; |
22
|
|
|
/** |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
private $options = []; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return string[] |
29
|
|
|
*/ |
30
|
|
|
public function getReadIndices(): array |
31
|
|
|
{ |
32
|
|
|
return $this->readIndices; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string[] $readIndices |
37
|
|
|
* @return $this |
38
|
|
|
*/ |
39
|
|
|
public function setReadIndices(array $readIndices) |
40
|
|
|
{ |
41
|
|
|
$this->readIndices = $readIndices; |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string[] |
47
|
|
|
*/ |
48
|
|
|
public function getWriteIndices(): array |
49
|
|
|
{ |
50
|
|
|
return $this->writeIndices; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string[] $writeIndices |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
|
|
public function setWriteIndices(array $writeIndices) |
58
|
|
|
{ |
59
|
|
|
$this->writeIndices = $writeIndices; |
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getType(): string |
67
|
|
|
{ |
68
|
|
|
return $this->type; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $type |
73
|
|
|
* @return $this |
74
|
|
|
*/ |
75
|
|
|
public function setType(string $type) |
76
|
|
|
{ |
77
|
|
|
$this->type = $type; |
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
|
|
public function getOptions(): array |
85
|
|
|
{ |
86
|
|
|
return $this->options; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param array $options |
91
|
|
|
* @return $this |
92
|
|
|
*/ |
93
|
|
|
public function setOptions(array $options) |
94
|
|
|
{ |
95
|
|
|
$this->options = $options; |
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public static function from(IndexingInterface $other): Indexing |
100
|
|
|
{ |
101
|
|
|
$target = new static(); |
102
|
|
|
if ($other->getType()) { |
103
|
|
|
$target->setType($other->getType()); |
104
|
|
|
} |
105
|
|
|
if ($other->getOptions()) { |
106
|
|
|
$target->setOptions($other->getOptions()); |
107
|
|
|
} |
108
|
|
|
if ($other->getReadIndices()) { |
109
|
|
|
$target->setReadIndices($other->getReadIndices()); |
110
|
|
|
} |
111
|
|
|
if ($other->getWriteIndices()) { |
112
|
|
|
$target->setWriteIndices($other->getWriteIndices()); |
113
|
|
|
} |
114
|
|
|
return $target; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|