Completed
Pull Request — master (#2)
by Guilh
02:45
created

Operation::getSummary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

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 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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\TagsPart;
12
use phootwork\collection\CollectionUtils;
13
use phootwork\lang\Arrayable;
14
15
class Operation extends AbstractModel implements Arrayable {
16
17
	use ConsumesPart;
18
	use ProducesPart;
19
	use TagsPart;
20
	use ParametersPart;
21
	use ResponsesPart;
22
	use SchemesPart;
23
	use ExternalDocsPart;
24
	use ExtensionPart;
25
26
	/** @var string */
27
	private $summary;
28
29
	/** @var string */
30
	private $description;
31
32
	/** @var string */
33
	private $operationId;
34
35
	/** @var boolean */
36 8
	private $deprecated = false;
37 8
38 8
	public function __construct($contents = []) {
39
		$this->parse($contents);
40 8
	}
41 8
42
	private function parse($contents = []) {
43 8
		$data = CollectionUtils::toMap($contents);
44 8
45 8
		$this->summary = $data->get('summary');
46 8
		$this->description = $data->get('description');
47
		$this->operationId = $data->get('operationId');
48
		$this->deprecated = $data->has('deprecated') && $data->get('deprecated');
49 8
50 8
		// parts
51 8
		$this->parseConsumes($data);
52 8
		$this->parseProduces($data);
53 8
		$this->parseTags($data);
54 8
		$this->parseParameters($data);
55 8
		$this->parseResponses($data);
56 8
		$this->parseSchemes($data);
57
		$this->parseExternalDocs($data);
58 6
		$this->parseExtensions($data);
59 6
	}
60 6
61
	public function toArray() {
62
		return $this->export('summary', 'description', 'operationId', 'deprecated',
63
				'consumes', 'produces', 'parameters', 'responses', 'schemes' 'tags',
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ')'
Loading history...
64
				'externalDocs');
65
	}
66
67
	/**
68
	 *
69
	 * @return the string
70
	 */
71
	public function getSummary() {
72
		return $this->summary;
73
	}
74
75
	/**
76
	 *
77
	 * @param string $summary
78
	 * @return $this
79
	 */
80
	public function setSummary($summary) {
81
		$this->summary = $summary;
82
		return $this;
83
	}
84
85
	/**
86
	 *
87
	 * @return string
88
	 */
89
	public function getDescription() {
90
		return $this->description;
91
	}
92
93
	/**
94
	 *
95
	 * @param string $description
96
	 */
97
	public function setDescription($description) {
98
		$this->description = $description;
99
		return $this;
100
	}
101
102
	/**
103
	 *
104
	 * @return string
105
	 */
106
	public function getOperationId() {
107
		return $this->operationId;
108
	}
109
110
	/**
111
	 *
112
	 * @param string $operationId
113
	 * @return $this
114
	 */
115
	public function setOperationId($operationId) {
116
		$this->operationId = $operationId;
117
		return $this;
118
	}
119
120
	/**
121
	 *
122
	 * @return boolean
123
	 */
124
	public function getDeprecated() {
125
		return $this->deprecated;
126
	}
127
128
	/**
129
	 *
130
	 * @param boolean $deprecated
131
	 * @return $this
132
	 */
133
	public function setDeprecated($deprecated) {
134
		$this->deprecated = $deprecated;
135
		return $this;
136
	}
137
138
139
}
140