Completed
Push — master ( 10a146...62fa38 )
by Thomas
8s
created

Operation::setDeprecated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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