-
Notifications
You must be signed in to change notification settings - Fork 5
/
Info.php
96 lines (79 loc) · 1.92 KB
/
Info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace WPOpenAPI\Spec;
class Info {
private string $title;
private string $version;
private ?string $summary = null;
private string $description;
private ?Contact $contact = null;
private ?License $license = null;
private ?string $termsOfService = null;
public function __construct( string $title, string $version, string $description, Contact $contact ) {
$this->title = $title;
$this->description = $description;
$this->version = $version;
$this->contact = $contact;
}
public function getContact(): Contact
{
return $this->contact;
}
/**
* @param string $summary A short summary of the API.
*
* @return void
*/
public function setSummary(string $summary)
{
$this->summary = $summary;
}
public function getSummary(): string
{
return $this->summary;
}
/**
* @param License $license The license information for the exposed API.
*
* @return void
*/
public function setLicense(License $license) {
$this->license = $license;
}
public function getLicense(): License
{
return $this->license;
}
/**
* @param string $termsOfServiceUrl A URL to the Terms of Service for the API. This MUST be in the form of a URL.
*
* @return void
*/
public function setTermsOfService(string $termsOfServiceUrl)
{
$this->termsOfService = $termsOfServiceUrl;
}
public function getTermsOfService(): string
{
return $this->termsOfService;
}
public function toArray(): array {
$data = array(
'title' => $this->title,
'description' => $this->description,
'version' => $this->version,
);
if ($this->summary) {
$data['summary'] = $this->summary;
}
if ($this->termsOfService) {
$data['termsOfService'] = $this->termsOfService;
}
if ($this->contact) {
$data['contact'] = $this->contact->toArray();
}
if ($this->license) {
$data['license'] = $this->license->toArray();
}
return $data;
}
}