|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Aweapi\Openapi\Objects; |
|
6
|
|
|
|
|
7
|
|
|
use Aweapi\Openapi\Extensions; |
|
8
|
|
|
use Aweapi\Openapi\ValueObject; |
|
9
|
|
|
|
|
10
|
|
|
final class MediaType extends ValueObject |
|
11
|
|
|
{ |
|
12
|
|
|
use Properties\OptionalExamples; |
|
13
|
|
|
use Properties\OptionalExtensions; |
|
14
|
|
|
|
|
15
|
|
|
private $encodings; |
|
16
|
|
|
|
|
17
|
|
|
private $schema; |
|
18
|
|
|
|
|
19
|
10 |
|
public function __construct( |
|
20
|
|
|
SchemaAggregate $schema = null, |
|
21
|
|
|
Examples $examples = null, |
|
22
|
|
|
Encodings $encodings = null, |
|
23
|
|
|
Extensions $extensions = null |
|
24
|
|
|
) { |
|
25
|
10 |
|
$this->schema = $schema; |
|
26
|
10 |
|
$this->examples = $examples; |
|
27
|
10 |
|
$this->encodings = $encodings; |
|
28
|
10 |
|
$this->extensions = $extensions; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
2 |
|
public function getEncodings(): Encodings |
|
32
|
|
|
{ |
|
33
|
2 |
|
return $this->encodings; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
7 |
|
public function getSchema(): SchemaAggregate |
|
37
|
|
|
{ |
|
38
|
7 |
|
return $this->schema; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
9 |
|
public function hasEncodings(): bool |
|
42
|
|
|
{ |
|
43
|
9 |
|
return isset($this->encodings); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
9 |
|
public function hasSchema(): bool |
|
47
|
|
|
{ |
|
48
|
9 |
|
return isset($this->schema); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
9 |
|
public function jsonSerialize(): ?array |
|
52
|
|
|
{ |
|
53
|
9 |
|
return $this->extendedProperties(parent::jsonSerialize()); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
9 |
|
protected function normalizeOptionalProperties(): array |
|
57
|
|
|
{ |
|
58
|
|
|
return [ |
|
59
|
9 |
|
'schema' => $this->hasSchema() ? $this->getSchema()->jsonSerialize() : null, |
|
60
|
9 |
|
'examples' => $this->getNormalizedExamples(), |
|
61
|
9 |
|
'encoding' => $this->hasEncodings() ? $this->getEncodings()->jsonSerialize() : null, |
|
62
|
|
|
]; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|