Completed
Push — master ( 8619b3...819e89 )
by Thomas
05:42
created

Response::getExamples()   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\DescriptionPart;
5
use phootwork\collection\CollectionUtils;
6
use gossi\swagger\parts\SchemaPart;
7
use phootwork\collection\Map;
8
use gossi\swagger\parts\RefPart;
9
use gossi\swagger\parts\ExtensionPart;
10
use phootwork\lang\Arrayable;
11
use gossi\swagger\collections\Headers;
12
13
class Response extends AbstractModel implements Arrayable {
14
	
15
	use RefPart;
16
	use DescriptionPart;
17
	use SchemaPart;
18
	use ExtensionPart;
19
	
20
	/** @var string */
21
	private $code;
22
	
23
	/** @var Map */
24
	private $examples;
25
	
26
	/** @var Headers */
27
	private $headers;
28
	
29 6
	public function __construct($code, $contents = []) {
30 6
		$this->code = $code;
31 6
		$this->parse($contents);
32 6
	}
33
	
34 6
	private function parse($contents = []) {
35 6
		$data = CollectionUtils::toMap($contents);
36
		
37 6
		$this->examples = $data->get('examples', new Map());
38 6
		$this->headers = new Headers($data->get('headers'));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
39
		
40
		// parts
41 6
		$this->parseRef($data);
42 6
		$this->parseDescription($data);
43 6
		$this->parseSchema($data);
44 6
		$this->parseExtensions($data);
45 6
	}
46
	
47 5
	public function toArray() {
48 5
		return $this->export('description', 'schema', 'headers', 'examples');
49
	}
50
51
	/**
52
	 * Returns the responses code
53
	 * 
54
	 * @return string
55
	 */
56 1
	public function getCode() {
57 1
		return $this->code;
58
	}
59
60
	/**
61
	 * 
62
	 * @return Map
63
	 */
64
	public function getExamples() {
65
		return $this->examples;
66
	}
67
	
68
	/**
69
	 * Returns headers for this response
70
	 * 
71
	 * @return Headers
72
	 */
73 1
	public function getHeaders() {
74 1
		return $this->headers;
75
	}
76
77
}