|
1
|
|
|
<?php |
|
2
|
|
|
namespace gossi\swagger; |
|
3
|
|
|
|
|
4
|
|
|
use gossi\swagger\parts\DescriptionPart; |
|
5
|
|
|
use gossi\swagger\parts\ExtensionPart; |
|
6
|
|
|
use phootwork\collection\CollectionUtils; |
|
7
|
|
|
use phootwork\collection\Map; |
|
8
|
|
|
use phootwork\lang\Arrayable; |
|
9
|
|
|
|
|
10
|
|
|
class Info extends AbstractModel implements Arrayable { |
|
11
|
|
|
|
|
12
|
|
|
use DescriptionPart; |
|
13
|
|
|
use ExtensionPart; |
|
14
|
|
|
|
|
15
|
|
|
/** @var string */ |
|
16
|
|
|
private $title; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string */ |
|
19
|
|
|
private $termsOfService; |
|
20
|
|
|
|
|
21
|
|
|
/** @var Contact */ |
|
22
|
|
|
private $contact; |
|
23
|
|
|
|
|
24
|
|
|
/** @var License */ |
|
25
|
|
|
private $license; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
private $version; |
|
29
|
|
|
|
|
30
|
10 |
|
public function __construct($contents = []) { |
|
31
|
10 |
|
$this->contact = new Contact(); |
|
32
|
10 |
|
$this->license = new License(); |
|
33
|
|
|
|
|
34
|
10 |
|
$this->merge($contents); |
|
35
|
10 |
|
} |
|
36
|
|
|
|
|
37
|
10 |
|
public function merge($contents, $strategy = self::PREFER_ORIGINAL) { |
|
38
|
10 |
|
$data = CollectionUtils::toMap($contents); |
|
39
|
|
|
|
|
40
|
10 |
|
$this->mergeFields($this->title, $data->get('title'), $strategy); |
|
41
|
10 |
|
$this->mergeFields($this->termsOfService, $data->get('termsOfService'), $strategy); |
|
42
|
10 |
|
$this->mergeFields($this->contact, $data->get('contact', new Map()), $strategy); |
|
43
|
10 |
|
$this->mergeFields($this->license, $data->get('license', new Map()), $strategy); |
|
44
|
10 |
|
$this->mergeFields($this->version, $data->get('version'), $strategy); |
|
45
|
|
|
|
|
46
|
|
|
// extensions |
|
47
|
10 |
|
$this->parseDescription($data); |
|
48
|
10 |
|
$this->parseExtensions($data); |
|
49
|
10 |
|
} |
|
50
|
|
|
|
|
51
|
7 |
|
public function toArray() { |
|
52
|
7 |
|
return $this->export('version', 'title', 'description', 'termsOfService', 'contact', 'license'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* |
|
57
|
|
|
* @return string |
|
58
|
|
|
*/ |
|
59
|
5 |
|
public function getTitle() { |
|
60
|
5 |
|
return $this->title; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* |
|
65
|
|
|
* @param string $title |
|
66
|
|
|
* @return $this |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function setTitle($title) { |
|
69
|
1 |
|
$this->title = $title; |
|
70
|
1 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
1 |
|
public function getTerms() { |
|
78
|
1 |
|
return $this->termsOfService; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* |
|
83
|
|
|
* @param string $terms |
|
84
|
|
|
* @return $this |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function setTerms($terms) { |
|
87
|
1 |
|
$this->termsOfService = $terms; |
|
88
|
1 |
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* |
|
93
|
|
|
* @return Contact |
|
94
|
|
|
*/ |
|
95
|
1 |
|
public function getContact() { |
|
96
|
1 |
|
return $this->contact; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* |
|
101
|
|
|
* @return License |
|
102
|
|
|
*/ |
|
103
|
1 |
|
public function getLicense() { |
|
104
|
1 |
|
return $this->license; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* |
|
109
|
|
|
* @return string |
|
110
|
|
|
*/ |
|
111
|
1 |
|
public function getVersion() { |
|
112
|
1 |
|
return $this->version; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* |
|
117
|
|
|
* @param string $version |
|
118
|
|
|
* @return $this |
|
119
|
|
|
*/ |
|
120
|
1 |
|
public function setVersion($version) { |
|
121
|
1 |
|
$this->version = $version; |
|
122
|
1 |
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
|