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

src/Parameter.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace gossi\swagger;
3
4
use gossi\swagger\parts\DescriptionPart;
5
use gossi\swagger\parts\ExtensionPart;
6
use gossi\swagger\parts\ItemsPart;
7
use gossi\swagger\parts\RequiredPart;
8
use gossi\swagger\parts\TypePart;
9
use phootwork\collection\CollectionUtils;
10
use gossi\swagger\parts\SchemaPart;
11
use gossi\swagger\parts\RefPart;
12
use phootwork\lang\Arrayable;
13
14
class Parameter extends AbstractModel implements Arrayable {
15
16
	use RefPart;
17
	use DescriptionPart;
18
	use SchemaPart;
19
	use TypePart;
20
	use ItemsPart;
21
	use RequiredPart;
22
	use ExtensionPart;
23
	
24
	/** @var string */
25
	private $name;
26
	
27
	/** @var string */
28
	private $in;
29
	
30
	/** @var boolean */
31
	private $allowEmptyValue = false;
32
	
33 4
	public function __construct($contents = []) {
34 4
		$this->parse($contents);
35 4
	}
36
	
37 4
	private function parse($contents = []) {
38 4
		$data = CollectionUtils::toMap($contents);
39
		
40 4
		$this->name = $data->get('name');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 12 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...
41 4
		$this->in = $data->get('in');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 14 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...
42 4
		$this->allowEmptyValue = $data->has('allowEmptyValue') && $data->get('allowEmptyValue');
43
		
44
45
		// parts
46 4
		$this->parseRef($data);
47 4
		$this->parseDescription($data);
48 4
		$this->parseSchema($data);
49 4
		$this->parseRequired($data);
50 4
		$this->parseType($data);
51 4
		$this->parseItems($data);
52 4
		$this->parseExtensions($data);
53 4
	}
54
	
55 3
	public function toArray() {
56 3
		return $this->export('name', 'in', 'allowEmptyValue', 'required', 'description', 'schema',
57 3
				$this->getTypeExportFields(), 'items');
58
	}
59
	
60
	/**
61
	 *
62
	 * @return string
63
	 */
64 1
	public function getName() {
65 1
		return $this->name;
66
	}
67
	
68
	/**
69
	 *
70
	 * @param string $name
71
	 */
72 1
	public function setName($name) {
73 1
		$this->name = $name;
74 1
		return $this;
75
	}
76
	
77
	/**
78
	 *
79
	 * @return string
80
	 */
81
	public function getIn() {
82
		return $this->in;
83
	}
84
	
85
	/**
86
	 *
87
	 * @param string $in
88
	 */
89
	public function setIn($in) {
90
		$this->in = $in;
91
		return $this;
92
	}
93
	
94
	/**
95
	 *
96
	 * @return boolean
97
	 */
98
	public function getAllowEmptyValue() {
99
		return $this->allowEmptyValue;
100
	}
101
	
102
	/**
103
	 * Sets the ability to pass empty-valued parameters. This is valid only for either `query` or 
104
	 * `formData` parameters and allows you to send a parameter with a name only or an empty value. 
105
	 * Default value is `false`.
106
	 * 
107
	 * @param boolean $allowEmptyValue
108
	 */
109
	public function setAllowEmptyValue($allowEmptyValue) {
110
		$this->allowEmptyValue = $allowEmptyValue;
111
		return $this;
112
	}
113
	
114
}