Passed
Push — master ( d463f7...97a77b )
by Jean-Christophe
02:20
created
Ajax/semantic/html/collections/form/HtmlFormField.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -19,38 +19,38 @@  discard block
 block discarded – undo
19 19
 
20 20
 	protected $_validation;
21 21
 
22
-	public function __construct($identifier, $field, $label = NULL) {
22
+	public function __construct($identifier, $field, $label=NULL) {
23 23
 		parent::__construct($identifier, "div", "field");
24
-		$this->content = array();
25
-		$this->_states = [
24
+		$this->content=array();
25
+		$this->_states=[
26 26
 			State::ERROR,
27 27
 			State::DISABLED
28 28
 		];
29
-		if (isset($label) && $label !== "")
29
+		if (isset($label) && $label!=="")
30 30
 			$this->setLabel($label);
31 31
 		$this->setField($field);
32
-		$this->_validation = NULL;
32
+		$this->_validation=NULL;
33 33
 	}
34 34
 
35
-	public function addPointingLabel($label, $pointing = Direction::NONE) {
36
-		$labelO = new HtmlLabel("", $label);
35
+	public function addPointingLabel($label, $pointing=Direction::NONE) {
36
+		$labelO=new HtmlLabel("", $label);
37 37
 		$labelO->setPointing($pointing);
38
-		$this->addContent($labelO, $pointing === "below" || $pointing === "right");
38
+		$this->addContent($labelO, $pointing==="below" || $pointing==="right");
39 39
 		return $labelO;
40 40
 	}
41 41
 
42 42
 	public function setLabel($label) {
43
-		$labelO = $label;
43
+		$labelO=$label;
44 44
 		if (\is_string($label)) {
45
-			$labelO = new HtmlSemDoubleElement("", "label", "");
45
+			$labelO=new HtmlSemDoubleElement("", "label", "");
46 46
 			$labelO->setContent($label);
47 47
 			$labelO->setProperty("for", \str_replace("field-", "", $this->identifier));
48 48
 		}
49
-		$this->content["label"] = $labelO;
49
+		$this->content["label"]=$labelO;
50 50
 	}
51 51
 
52 52
 	public function setField($field) {
53
-		$this->content["field"] = $field;
53
+		$this->content["field"]=$field;
54 54
 	}
55 55
 
56 56
 	/**
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * puts the label before or behind
86 86
 	 */
87 87
 	public function swapLabel() {
88
-		$label = $this->getLabel();
88
+		$label=$this->getLabel();
89 89
 		unset($this->content["label"]);
90
-		$this->content["label"] = $label;
90
+		$this->content["label"]=$label;
91 91
 	}
92 92
 
93 93
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function setWidth($width) {
100 100
 		if (\is_int($width)) {
101
-			$width = Wide::getConstants()["W" . $width];
101
+			$width=Wide::getConstants()["W".$width];
102 102
 		}
103 103
 		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
104 104
 		if (isset($this->_container)) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	public function setContainer($_container) {
130
-		$this->_container = $_container;
130
+		$this->_container=$_container;
131 131
 		return $this;
132 132
 	}
133 133
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 		$this->getDataField()->setProperty("readonly", "");
136 136
 	}
137 137
 
138
-	public function addRule($type, $prompt = NULL, $value = NULL) {
139
-		$field = $this->getDataField();
138
+	public function addRule($type, $prompt=NULL, $value=NULL) {
139
+		$field=$this->getDataField();
140 140
 		if (isset($field)) {
141
-			if (! isset($this->_validation)) {
142
-				$this->_validation = new FieldValidation($field->getIdentifier());
141
+			if (!isset($this->_validation)) {
142
+				$this->_validation=new FieldValidation($field->getIdentifier());
143 143
 			}
144
-			if($type instanceof Rule){
145
-				if($type->getType()=='empty'){
144
+			if ($type instanceof Rule) {
145
+				if ($type->getType()=='empty') {
146 146
 					$this->addToProperty('class', 'required');
147 147
 				}
148
-			}elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
148
+			}elseif ($type==='empty' || ($type['type'] ?? '')==='empty') {
149 149
 				$this->addToProperty('class', 'required');
150 150
 			}
151 151
 			$this->_validation->addRule($type, $prompt, $value);
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 		return $this;
154 154
 	}
155 155
 
156
-	public function setOptional($optional = true) {
157
-		$field = $this->getDataField();
156
+	public function setOptional($optional=true) {
157
+		$field=$this->getDataField();
158 158
 		if (isset($field)) {
159
-			if (! isset($this->_validation)) {
160
-				$this->_validation = new FieldValidation($field->getIdentifier());
159
+			if (!isset($this->_validation)) {
160
+				$this->_validation=new FieldValidation($field->getIdentifier());
161 161
 			}
162 162
 			$this->_validation->setOptional($optional);
163 163
 		}
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 	public function setRules(array $rules) {
174
-		$this->_validation = null;
174
+		$this->_validation=null;
175 175
 		return $this->addRules($rules);
176 176
 	}
177 177
 
178
-	public function addIcon($icon, $direction = Direction::LEFT) {
179
-		$field = $this->getField();
178
+	public function addIcon($icon, $direction=Direction::LEFT) {
179
+		$field=$this->getField();
180 180
 		return $field->addIcon($icon, $direction);
181 181
 	}
182 182
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,8 +26,9 @@  discard block
 block discarded – undo
26 26
 			State::ERROR,
27 27
 			State::DISABLED
28 28
 		];
29
-		if (isset($label) && $label !== "")
30
-			$this->setLabel($label);
29
+		if (isset($label) && $label !== "") {
30
+					$this->setLabel($label);
31
+		}
31 32
 		$this->setField($field);
32 33
 		$this->_validation = NULL;
33 34
 	}
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 	 * @return mixed
60 61
 	 */
61 62
 	public function getLabel() {
62
-		if (\array_key_exists("label", $this->content))
63
-			return $this->content["label"];
63
+		if (\array_key_exists("label", $this->content)) {
64
+					return $this->content["label"];
65
+		}
64 66
 	}
65 67
 
66 68
 	/**
@@ -145,7 +147,7 @@  discard block
 block discarded – undo
145 147
 				if($type->getType()=='empty'){
146 148
 					$this->addToProperty('class', 'required');
147 149
 				}
148
-			}elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
150
+			} elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
149 151
 				$this->addToProperty('class', 'required');
150 152
 			}
151 153
 			$this->_validation->addRule($type, $prompt, $value);
Please login to merge, or discard this patch.