Info::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 11
	public function __construct($contents = []) {
31 11
		$this->parse($contents);
32 11
	}
33
34 11
	private function parse($contents = []) {
35 11
		$data = CollectionUtils::toMap($contents);
36
37 11
		$this->title = $data->get('title');
38 11
		$this->termsOfService = $data->get('termsOfService');
39 11
		$this->contact = new Contact($data->get('contact', new Map()));
40 11
		$this->license = new License($data->get('license', new Map()));
41 11
		$this->version = $data->get('version');
42
43
		// extensions
44 11
		$this->parseDescription($data);
45 11
		$this->parseExtensions($data);
46 11
	}
47
48 8
	public function toArray() {
49 8
		return $this->export('version', 'title', 'description', 'termsOfService', 'contact', 'license');
50
	}
51
52
	/**
53
	 *
54
	 * @return string
55
	 */
56 1
	public function getTitle() {
57 1
		return $this->title;
58
	}
59
60
	/**
61
	 *
62
	 * @param string $title
63
	 * @return $this
64
	 */
65 1
	public function setTitle($title) {
66 1
		$this->title = $title;
67 1
		return $this;
68
	}
69
70
	/**
71
	 *
72
	 * @return string
73
	 */
74 1
	public function getTerms() {
75 1
		return $this->termsOfService;
76
	}
77
78
	/**
79
	 *
80
	 * @param string $terms
81
	 * @return $this
82
	 */
83 1
	public function setTerms($terms) {
84 1
		$this->termsOfService = $terms;
85 1
		return $this;
86
	}
87
88
	/**
89
	 *
90
	 * @return Contact
91
	 */
92 1
	public function getContact() {
93 1
		return $this->contact;
94
	}
95
96
	/**
97
	 *
98
	 * @return License
99
	 */
100 1
	public function getLicense() {
101 1
		return $this->license;
102
	}
103
104
	/**
105
	 *
106
	 * @return string
107
	 */
108 1
	public function getVersion() {
109 1
		return $this->version;
110
	}
111
112
	/**
113
	 *
114
	 * @param string $version
115
	 * @return $this
116
	 */
117 1
	public function setVersion($version) {
118 1
		$this->version = $version;
119 1
		return $this;
120
	}
121
122
}
123