1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AmaTeam\ElasticSearch\API\Entity\Mapping\Structure; |
4
|
|
|
|
5
|
|
|
class View implements ViewInterface |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var string |
9
|
|
|
*/ |
10
|
|
|
private $type; |
11
|
|
|
/** |
12
|
|
|
* @var array |
13
|
|
|
*/ |
14
|
|
|
private $parameters = []; |
15
|
|
|
/** |
16
|
|
|
* @var string[] |
17
|
|
|
*/ |
18
|
|
|
private $ignoredProperties = []; |
19
|
|
|
/** |
20
|
|
|
* @var string[] |
21
|
|
|
*/ |
22
|
|
|
private $existingProperties = []; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @return string |
26
|
|
|
*/ |
27
|
|
|
public function getType(): ?string |
28
|
|
|
{ |
29
|
|
|
return $this->type; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $type |
34
|
|
|
* @return $this |
35
|
|
|
*/ |
36
|
|
|
public function setType(string $type): View |
37
|
|
|
{ |
38
|
|
|
$this->type = $type; |
39
|
|
|
return $this; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return array |
44
|
|
|
*/ |
45
|
|
|
public function getParameters(): array |
46
|
|
|
{ |
47
|
|
|
return $this->parameters; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param array $parameters |
52
|
|
|
* @return $this |
53
|
|
|
*/ |
54
|
|
|
public function setParameters(array $parameters): View |
55
|
|
|
{ |
56
|
|
|
$this->parameters = $parameters; |
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function hasParameter(string $parameter): bool |
61
|
|
|
{ |
62
|
|
|
return isset($this->parameters[$parameter]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getParameter(string $parameter) |
66
|
|
|
{ |
67
|
|
|
return $this->parameters[$parameter] ?? null; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setParameter(string $parameter, $value): View |
71
|
|
|
{ |
72
|
|
|
$this->parameters[$parameter] = $value; |
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return string[] |
78
|
|
|
*/ |
79
|
|
|
public function getIgnoredProperties(): array |
80
|
|
|
{ |
81
|
|
|
return array_values($this->ignoredProperties); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function setIgnoredProperties(array $properties): View |
85
|
|
|
{ |
86
|
|
|
$this->ignoredProperties = []; |
87
|
|
|
foreach ($properties as $property) { |
88
|
|
|
$this->addIgnoredProperty($property); |
89
|
|
|
} |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param string $property |
95
|
|
|
* @return View |
96
|
|
|
*/ |
97
|
|
|
public function addIgnoredProperty(string $property): View |
98
|
|
|
{ |
99
|
|
|
$this->ignoredProperties[$property] = $property; |
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function forgetIgnoredProperty(string $name): View |
104
|
|
|
{ |
105
|
|
|
unset($this->ignoredProperties[$name]); |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return string[] |
111
|
|
|
*/ |
112
|
|
|
public function getExistingProperties(): array |
113
|
|
|
{ |
114
|
|
|
return array_values($this->existingProperties); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param string[] $existingProperties |
119
|
|
|
* @return $this |
120
|
|
|
*/ |
121
|
|
|
public function setExistingProperties(array $existingProperties): View |
122
|
|
|
{ |
123
|
|
|
$this->existingProperties = []; |
124
|
|
|
foreach ($existingProperties as $property) { |
125
|
|
|
$this->addExistingProperty($property); |
126
|
|
|
} |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function addExistingProperty(string $property): View |
131
|
|
|
{ |
132
|
|
|
$this->existingProperties[$property] = $property; |
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function forgetExistingProperty(string $property): View |
137
|
|
|
{ |
138
|
|
|
unset($this->existingProperties[$property]); |
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|