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 Response extends ValueObject implements ResponseAggregate |
11
|
|
|
{ |
12
|
|
|
use Properties\Description; |
13
|
|
|
use Properties\OptionalMediaTypeContent; |
14
|
|
|
use Properties\OptionalExtensions; |
15
|
|
|
|
16
|
|
|
private $headers; |
17
|
|
|
|
18
|
|
|
private $links; |
19
|
|
|
|
20
|
8 |
|
public function __construct( |
21
|
|
|
string $description, |
22
|
|
|
Headers $headers = null, |
23
|
|
|
MediaTypes $content = null, |
24
|
|
|
Links $links = null, |
25
|
|
|
Extensions $extensions = null |
26
|
|
|
) { |
27
|
8 |
|
$this->description = $description; |
28
|
8 |
|
$this->headers = $headers; |
29
|
8 |
|
$this->content = $content; |
30
|
8 |
|
$this->links = $links; |
31
|
8 |
|
$this->extensions = $extensions; |
32
|
|
|
} |
33
|
|
|
|
34
|
1 |
|
public function getHeaders(): Headers |
35
|
|
|
{ |
36
|
1 |
|
return $this->headers; |
37
|
|
|
} |
38
|
|
|
|
39
|
1 |
|
public function getLinks(): Links |
40
|
|
|
{ |
41
|
1 |
|
return $this->links; |
42
|
|
|
} |
43
|
|
|
|
44
|
7 |
|
public function hasHeaders(): bool |
45
|
|
|
{ |
46
|
7 |
|
return isset($this->headers); |
47
|
|
|
} |
48
|
|
|
|
49
|
7 |
|
public function hasLinks(): bool |
50
|
|
|
{ |
51
|
7 |
|
return isset($this->links); |
52
|
|
|
} |
53
|
|
|
|
54
|
7 |
|
public function jsonSerialize(): ?array |
55
|
|
|
{ |
56
|
7 |
|
return $this->extendedProperties(parent::jsonSerialize()); |
57
|
|
|
} |
58
|
|
|
|
59
|
7 |
|
protected function normalizeOptionalProperties(): array |
60
|
|
|
{ |
61
|
|
|
return [ |
62
|
7 |
|
'headers' => $this->hasHeaders() ? $this->getHeaders()->jsonSerialize() : null, |
63
|
7 |
|
'content' => $this->getNormalizedContent(), |
64
|
7 |
|
'links' => $this->hasLinks() ? $this->getLinks()->jsonSerialize() : null, |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
|
68
|
7 |
|
protected function normalizeRequiredProperties(): array |
69
|
|
|
{ |
70
|
|
|
return [ |
71
|
7 |
|
'description' => $this->getDescription(), |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|