1 | <?php |
||
23 | final class PropertyMetadata |
||
24 | { |
||
25 | private $type; |
||
26 | private $description; |
||
27 | private $readable; |
||
28 | private $writable; |
||
29 | private $readableLink; |
||
30 | private $writableLink; |
||
31 | private $required; |
||
32 | private $iri; |
||
33 | private $identifier; |
||
34 | private $childInherited; |
||
35 | private $attributes; |
||
36 | |||
37 | public function __construct(Type $type = null, string $description = null, bool $readable = null, bool $writable = null, bool $readableLink = null, bool $writableLink = null, bool $required = null, bool $identifier = null, string $iri = null, $childInherited = null, array $attributes = null) |
||
38 | { |
||
39 | $this->type = $type; |
||
40 | $this->description = $description; |
||
41 | $this->readable = $readable; |
||
42 | $this->writable = $writable; |
||
43 | $this->readableLink = $readableLink; |
||
44 | $this->writableLink = $writableLink; |
||
45 | $this->required = $required; |
||
46 | $this->identifier = $identifier; |
||
47 | $this->iri = $iri; |
||
48 | $this->childInherited = $childInherited; |
||
49 | $this->attributes = $attributes; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Gets type. |
||
54 | * |
||
55 | * @return Type|null |
||
56 | */ |
||
57 | public function getType() |
||
61 | |||
62 | /** |
||
63 | * Returns a new instance with the given type. |
||
64 | * |
||
65 | * @param Type $type |
||
66 | * |
||
67 | * @return self |
||
68 | */ |
||
69 | public function withType(Type $type): self |
||
76 | |||
77 | /** |
||
78 | * Gets description. |
||
79 | * |
||
80 | * @return string|null |
||
81 | */ |
||
82 | public function getDescription() |
||
86 | |||
87 | /** |
||
88 | * Returns a new instance with the given description. |
||
89 | * |
||
90 | * @param string $description |
||
91 | * |
||
92 | * @return self |
||
93 | */ |
||
94 | public function withDescription($description): self |
||
101 | |||
102 | /** |
||
103 | * Is readable? |
||
104 | * |
||
105 | * @return bool|null |
||
106 | */ |
||
107 | public function isReadable() |
||
111 | |||
112 | /** |
||
113 | * Returns a new instance of Metadata with the given readable flag. |
||
114 | * |
||
115 | * @param bool $readable |
||
116 | * |
||
117 | * @return self |
||
118 | */ |
||
119 | public function withReadable(bool $readable): self |
||
126 | |||
127 | /** |
||
128 | * Is writable? |
||
129 | * |
||
130 | * @return bool|null |
||
131 | */ |
||
132 | public function isWritable() |
||
136 | |||
137 | /** |
||
138 | * Returns a new instance with the given writable flag. |
||
139 | * |
||
140 | * @param bool $writable |
||
141 | * |
||
142 | * @return self |
||
143 | */ |
||
144 | public function withWritable(bool $writable): self |
||
151 | |||
152 | /** |
||
153 | * Is required? |
||
154 | * |
||
155 | * @return bool|null |
||
156 | */ |
||
157 | public function isRequired() |
||
165 | |||
166 | /** |
||
167 | * Returns a new instance with the given required flag. |
||
168 | * |
||
169 | * @param bool $required |
||
170 | * |
||
171 | * @return self |
||
172 | */ |
||
173 | public function withRequired(bool $required): self |
||
180 | |||
181 | /** |
||
182 | * Should an IRI or an object be provided in write context? |
||
183 | * |
||
184 | * @return bool|null |
||
185 | */ |
||
186 | public function isWritableLink() |
||
190 | |||
191 | /** |
||
192 | * Returns a new instance with the given writable link flag. |
||
193 | * |
||
194 | * @param bool $writableLink |
||
195 | * |
||
196 | * @return self |
||
197 | */ |
||
198 | public function withWritableLink(bool $writableLink): self |
||
205 | |||
206 | /** |
||
207 | * Is an IRI or an object generated in read context? |
||
208 | * |
||
209 | * @return bool|null |
||
210 | */ |
||
211 | public function isReadableLink() |
||
215 | |||
216 | /** |
||
217 | * Returns a new instance with the given readable link flag. |
||
218 | * |
||
219 | * @param bool $readableLink |
||
220 | * |
||
221 | * @return self |
||
222 | */ |
||
223 | public function withReadableLink(bool $readableLink): self |
||
230 | |||
231 | /** |
||
232 | * Gets IRI of this property. |
||
233 | * |
||
234 | * @return string|null |
||
235 | */ |
||
236 | public function getIri() |
||
240 | |||
241 | /** |
||
242 | * Returns a new instance with the given IRI. |
||
243 | * |
||
244 | * @param string|null $iri |
||
245 | * |
||
246 | * @return self |
||
247 | */ |
||
248 | public function withIri(string $iri = null): self |
||
255 | |||
256 | /** |
||
257 | * Is this attribute an identifier? |
||
258 | * |
||
259 | * @return bool|null |
||
260 | */ |
||
261 | public function isIdentifier() |
||
265 | |||
266 | /** |
||
267 | * Returns a new instance with the given identifier flag. |
||
268 | * |
||
269 | * @param bool $identifier |
||
270 | * |
||
271 | * @return self |
||
272 | */ |
||
273 | public function withIdentifier(bool $identifier): self |
||
280 | |||
281 | /** |
||
282 | * Gets attributes. |
||
283 | * |
||
284 | * @return array|null |
||
285 | */ |
||
286 | public function getAttributes() |
||
290 | |||
291 | /** |
||
292 | * Gets an attribute. |
||
293 | * |
||
294 | * @param string $key |
||
295 | * @param mixed $defaultValue |
||
296 | * |
||
297 | * @return mixed |
||
298 | */ |
||
299 | public function getAttribute(string $key, $defaultValue = null) |
||
307 | |||
308 | /** |
||
309 | * Returns a new instance with the given attribute. |
||
310 | * |
||
311 | * @param array $attributes |
||
312 | * |
||
313 | * @return self |
||
314 | */ |
||
315 | public function withAttributes(array $attributes): self |
||
322 | |||
323 | /** |
||
324 | * Is the property inherited from a child class? |
||
325 | * |
||
326 | * @return string|null |
||
327 | */ |
||
328 | public function isChildInherited() |
||
332 | |||
333 | /** |
||
334 | * Returns a new instance with the given child inherited class. |
||
335 | * |
||
336 | * @param string $childInherited |
||
337 | * |
||
338 | * @return self |
||
339 | */ |
||
340 | public function withChildInherited(string $childInherited): self |
||
347 | } |
||
348 |