Operation::setDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
namespace gossi\swagger;
3
4
use gossi\swagger\parts\ConsumesPart;
5
use gossi\swagger\parts\ExtensionPart;
6
use gossi\swagger\parts\ExternalDocsPart;
7
use gossi\swagger\parts\ParametersPart;
8
use gossi\swagger\parts\ProducesPart;
9
use gossi\swagger\parts\ResponsesPart;
10
use gossi\swagger\parts\SchemesPart;
11
use gossi\swagger\parts\SecurityPart;
12
use gossi\swagger\parts\TagsPart;
13
use phootwork\collection\CollectionUtils;
14
use phootwork\lang\Arrayable;
15
16
class Operation extends AbstractModel implements Arrayable {
17
18
	use ConsumesPart;
19
	use ProducesPart;
20
	use TagsPart;
21
	use SecurityPart;
22
	use ParametersPart;
23
	use ResponsesPart;
24
	use SchemesPart;
25
	use ExternalDocsPart;
26
	use ExtensionPart;
27
28
	/** @var string */
29
	private $summary;
30
31
	/** @var string */
32
	private $description;
33
34
	/** @var string */
35
	private $operationId;
36
37
	/** @var bool */
38
	private $deprecated = false;
39
40 9
	public function __construct($contents = []) {
41 9
		$this->parse($contents);
42 9
	}
43
44 9
	private function parse($contents = []) {
45 9
		$data = CollectionUtils::toMap($contents);
46
47 9
		$this->summary = $data->get('summary');
48 9
		$this->description = $data->get('description');
49 9
		$this->operationId = $data->get('operationId');
50 9
		$this->deprecated = $data->has('deprecated') && $data->get('deprecated');
51
52
		// parts
53 9
		$this->parseConsumes($data);
54 9
		$this->parseProduces($data);
55 9
		$this->parseTags($data);
56 9
		$this->parseParameters($data);
57 9
		$this->parseResponses($data);
58 9
		$this->parseSchemes($data);
59 9
		$this->parseSecurity($data);
60 9
		$this->parseExternalDocs($data);
61 9
		$this->parseExtensions($data);
62 9
	}
63
64 7
	public function toArray() {
65 7
		return $this->export('summary', 'description', 'operationId', 'deprecated',
66 7
				'consumes', 'produces', 'parameters', 'responses', 'schemes',
67 7
				'security', 'tags', 'externalDocs');
68
	}
69
70
	/**
71
	 *
72
	 * @return string
73
	 */
74
	public function getSummary() {
75
		return $this->summary;
76
	}
77
78
	/**
79
	 *
80
	 * @param string $summary
81
	 * @return $this
82
	 */
83
	public function setSummary($summary) {
84
		$this->summary = $summary;
85
		return $this;
86
	}
87
88
	/**
89
	 *
90
	 * @return string
91
	 */
92
	public function getDescription() {
93
		return $this->description;
94
	}
95
96
	/**
97
	 *
98
	 * @param string $description
99
	 */
100
	public function setDescription($description) {
101
		$this->description = $description;
102
		return $this;
103
	}
104
105
	/**
106
	 *
107
	 * @return string
108
	 */
109
	public function getOperationId() {
110
		return $this->operationId;
111
	}
112
113
	/**
114
	 *
115
	 * @param string $operationId
116
	 * @return $this
117
	 */
118
	public function setOperationId($operationId) {
119
		$this->operationId = $operationId;
120
		return $this;
121
	}
122
123
	/**
124
	 *
125
	 * @return bool
126
	 */
127
	public function getDeprecated() {
128
		return $this->deprecated;
129
	}
130
131
	/**
132
	 *
133
	 * @param bool $deprecated
134
	 * @return $this
135
	 */
136
	public function setDeprecated($deprecated) {
137
		$this->deprecated = $deprecated;
138
		return $this;
139
	}
140
141
}
142