Passed
Push — master ( d1be46...8a7fa4 )
by Paul
04:27
created
plugin/Modules/Html/Builder.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function __call( $method, $args )
61 61
 	{
62
-		$instance = new static( $this->globals );
62
+		$instance = new static($this->globals);
63 63
 		$instance->setTagFromMethod( $method );
64
-		call_user_func_array( [$instance, 'normalize'], $args += ['',''] );
64
+		call_user_func_array( [$instance, 'normalize'], $args += ['', ''] );
65 65
 		$tags = array_merge( static::TAGS_FORM, static::TAGS_STRUCTURE, static::TAGS_TEXT );
66 66
 		$generatedTag = in_array( $instance->tag, $tags )
67 67
 			? $instance->buildTag()
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 			'render' => 'is_bool',
86 86
 			'tag' => 'is_string',
87 87
 		];
88
-		if( !isset( $properties[$property] )
89
-			|| empty( array_filter( [$value], $properties[$property] ))
88
+		if( !isset($properties[$property])
89
+			|| empty(array_filter( [$value], $properties[$property] ))
90 90
 		)return;
91 91
 		$this->$property = $value;
92 92
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function getOpeningTag()
106 106
 	{
107
-		$attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString();
107
+		$attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString();
108 108
 		return '<'.trim( $this->tag.' '.$attributes ).'>';
109 109
 	}
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	protected function buildCustomField()
115 115
 	{
116 116
 		$className = glsr( Helper::class )->buildClassName( $this->tag, __NAMESPACE__.'\Fields' );
117
-		if( !class_exists( $className )) {
117
+		if( !class_exists( $className ) ) {
118 118
 			glsr_log()->error( 'Field missing: '.$className );
119 119
 			return;
120 120
 		}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function buildDefaultTag( $text = '' )
128 128
 	{
129
-		if( empty( $text )) {
129
+		if( empty($text) ) {
130 130
 			$text = $this->args['text'];
131 131
 		}
132 132
 		return $this->getOpeningTag().$text.$this->getClosingTag();
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	protected function buildFieldDescription()
139 139
 	{
140
-		if( empty( $this->args['description'] ))return;
141
-		if( !empty( $this->globals['is_widget'] )) {
140
+		if( empty($this->args['description']) )return;
141
+		if( !empty($this->globals['is_widget']) ) {
142 142
 			return $this->small( $this->args['description'] );
143 143
 		}
144 144
 		return $this->p( $this->args['description'], ['class' => 'description'] );
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	protected function buildFormInput()
151 151
 	{
152
-		if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) {
152
+		if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) {
153 153
 			return $this->buildFormLabel().$this->getOpeningTag();
154 154
 		}
155
-		return empty( $this->args['options'] )
155
+		return empty($this->args['options'])
156 156
 			? $this->buildFormInputChoice()
157 157
 			: $this->buildFormInputMultiChoice();
158 158
 	}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	protected function buildFormInputMultiChoice()
172 172
 	{
173 173
 		if( $this->args['type'] == 'checkbox' ) {
174
-			$this->args['name'].= '[]';
174
+			$this->args['name'] .= '[]';
175 175
 		}
176 176
 		$options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
177 177
 			return $carry.$this->li( $this->{$this->args['type']}([
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 				'name' => $this->args['name'],
180 180
 				'text' => $this->args['options'][$key],
181 181
 				'value' => $key,
182
-			]));
182
+			]) );
183 183
 		});
184 184
 		return $this->ul( $options, [
185 185
 			'class' => $this->args['class'],
186 186
 			'id' => $this->args['id'],
187
-		]);
187
+		] );
188 188
 	}
189 189
 
190 190
 	/**
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	protected function buildFormLabel()
194 194
 	{
195
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
196
-		return $this->label([
195
+		if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return;
196
+		return $this->label( [
197 197
 			'for' => $this->args['id'],
198 198
 			'text' => $this->args['label'],
199
-		]);
199
+		] );
200 200
 	}
201 201
 
202 202
 	/**
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	protected function buildFormSelectOptions()
214 214
 	{
215 215
 		return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
216
-			return $carry.$this->option([
216
+			return $carry.$this->option( [
217 217
 				'selected' => $this->args['value'] == $key,
218 218
 				'text' => $this->args['options'][$key],
219 219
 				'value' => $key,
220
-			]);
220
+			] );
221 221
 		});
222 222
 	}
223 223
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	protected function buildTag()
236 236
 	{
237
-		if( !in_array( $this->tag, static::TAGS_FORM )) {
237
+		if( !in_array( $this->tag, static::TAGS_FORM ) ) {
238 238
 			return $this->buildDefaultTag();
239 239
 		}
240 240
 		return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription();
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	protected function normalize( ...$params )
248 248
 	{
249
-		if( is_string( $params[0] ) || is_numeric( $params[0] )) {
249
+		if( is_string( $params[0] ) || is_numeric( $params[0] ) ) {
250 250
 			$this->setNameOrTextAttributeForTag( $params[0] );
251 251
 		}
252
-		if( is_array( $params[0] )) {
252
+		if( is_array( $params[0] ) ) {
253 253
 			$this->args += $params[0];
254 254
 		}
255
-		else if( is_array( $params[1] )) {
255
+		else if( is_array( $params[1] ) ) {
256 256
 			$this->args += $params[1];
257 257
 		}
258 258
 		$this->args = glsr( BuilderDefaults::class )->merge( $this->args );
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	protected function setTagFromMethod( $method )
278 278
 	{
279 279
 		$this->tag = strtolower( $method );
280
-		if( in_array( $this->tag, static::INPUT_TYPES )) {
280
+		if( in_array( $this->tag, static::INPUT_TYPES ) ) {
281 281
 			$this->args['type'] = $this->tag;
282 282
 			$this->tag = 'input';
283 283
 		}
Please login to merge, or discard this patch.