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

Response   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Test Coverage

Coverage 90.48%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
c 3
b 0
f 0
lcom 1
cbo 8
dl 0
loc 65
ccs 19
cts 21
cp 0.9048
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 12 1
A toArray() 0 3 1
A getCode() 0 3 1
A getExamples() 0 3 1
A getHeaders() 0 3 1
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
}