|
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 Info extends ValueObject |
|
11
|
|
|
{ |
|
12
|
|
|
use Properties\OptionalDescription; |
|
13
|
|
|
use Properties\OptionalExtensions; |
|
14
|
|
|
|
|
15
|
|
|
private $contact; |
|
16
|
|
|
|
|
17
|
|
|
private $license; |
|
18
|
|
|
|
|
19
|
|
|
private $termsOfService; |
|
20
|
|
|
|
|
21
|
|
|
private $title; |
|
22
|
|
|
|
|
23
|
|
|
private $version; |
|
24
|
|
|
|
|
25
|
4 |
|
public function __construct( |
|
26
|
|
|
string $title, |
|
27
|
|
|
string $version, |
|
28
|
|
|
string $description = null, |
|
29
|
|
|
string $termsOfService = null, |
|
30
|
|
|
Contact $contact = null, |
|
31
|
|
|
License $license = null, |
|
32
|
|
|
Extensions $extensions = null |
|
33
|
|
|
) { |
|
34
|
4 |
|
$this->title = $title; |
|
35
|
4 |
|
$this->version = $version; |
|
36
|
4 |
|
$this->description = $description; |
|
37
|
4 |
|
$this->termsOfService = $termsOfService; |
|
38
|
4 |
|
$this->contact = $contact; |
|
39
|
4 |
|
$this->license = $license; |
|
40
|
4 |
|
$this->extensions = $extensions; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
public function getContact(): Contact |
|
44
|
|
|
{ |
|
45
|
1 |
|
return $this->contact; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
public function getLicense(): License |
|
49
|
|
|
{ |
|
50
|
1 |
|
return $this->license; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
1 |
|
public function getTermsOfService(): string |
|
54
|
|
|
{ |
|
55
|
1 |
|
return $this->termsOfService; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
4 |
|
public function getTitle(): string |
|
59
|
|
|
{ |
|
60
|
4 |
|
return $this->title; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
4 |
|
public function getVersion(): string |
|
64
|
|
|
{ |
|
65
|
4 |
|
return $this->version; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
4 |
|
public function hasContact(): bool |
|
69
|
|
|
{ |
|
70
|
4 |
|
return isset($this->contact); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
4 |
|
public function hasLicense(): bool |
|
74
|
|
|
{ |
|
75
|
4 |
|
return isset($this->license); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
4 |
|
public function hasTermsOfService(): bool |
|
79
|
|
|
{ |
|
80
|
4 |
|
return isset($this->termsOfService); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
4 |
|
public function jsonSerialize(): ?array |
|
84
|
|
|
{ |
|
85
|
4 |
|
return $this->extendedProperties(parent::jsonSerialize()); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
4 |
|
protected function normalizeOptionalProperties(): array |
|
89
|
|
|
{ |
|
90
|
|
|
return [ |
|
91
|
4 |
|
'description' => $this->getNormalizedDescription(), |
|
92
|
4 |
|
'termsOfService' => $this->hasTermsOfService() ? $this->getTermsOfService() : null, |
|
93
|
4 |
|
'contact' => $this->hasContact() ? $this->getContact()->jsonSerialize() : null, |
|
94
|
4 |
|
'license' => $this->hasLicense() ? $this->getLicense()->jsonSerialize() : null, |
|
95
|
|
|
]; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
4 |
|
protected function normalizeRequiredProperties(): array |
|
99
|
|
|
{ |
|
100
|
|
|
return [ |
|
101
|
4 |
|
'title' => $this->getTitle(), |
|
102
|
4 |
|
'version' => $this->getVersion(), |
|
103
|
|
|
]; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|