Passed
Push — master ( 60c13a...992102 )
by Paul
04:54
created
plugin/Modules/Html/Builder.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function __call( $method, $args )
65 65
 	{
66
-		$instance = new static( $this->globals );
66
+		$instance = new static($this->globals);
67 67
 		$instance->setTagFromMethod( $method );
68
-		call_user_func_array( [$instance, 'normalize'], $args += ['',''] );
68
+		call_user_func_array( [$instance, 'normalize'], $args += ['', ''] );
69 69
 		$tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT );
70 70
 		$generatedTag = in_array( $instance->tag, $tags )
71 71
 			? $instance->buildTag()
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 			'render' => 'is_bool',
90 90
 			'tag' => 'is_string',
91 91
 		];
92
-		if( !isset( $properties[$property] )
93
-			|| empty( array_filter( [$value], $properties[$property] ))
92
+		if( !isset($properties[$property])
93
+			|| empty(array_filter( [$value], $properties[$property] ))
94 94
 		)return;
95 95
 		$this->$property = $value;
96 96
 	}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function getOpeningTag()
110 110
 	{
111
-		$attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString();
111
+		$attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString();
112 112
 		return '<'.trim( $this->tag.' '.$attributes ).'>';
113 113
 	}
114 114
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	protected function buildCustomField()
119 119
 	{
120 120
 		$className = $this->getCustomFieldClassName();
121
-		if( class_exists( $className )) {
121
+		if( class_exists( $className ) ) {
122 122
 			return (new $className( $this ))->build();
123 123
 		}
124 124
 		glsr_log()->error( 'Field missing: '.$className );
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	protected function buildDefaultTag( $text = '' )
131 131
 	{
132
-		if( empty( $text )) {
132
+		if( empty($text) ) {
133 133
 			$text = $this->args['text'];
134 134
 		}
135 135
 		return $this->getOpeningTag().$text.$this->getClosingTag();
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	protected function buildFieldDescription()
142 142
 	{
143
-		if( empty( $this->args['description'] ))return;
144
-		if( !empty( $this->globals['is_widget'] )) {
143
+		if( empty($this->args['description']) )return;
144
+		if( !empty($this->globals['is_widget']) ) {
145 145
 			return $this->small( $this->args['description'] );
146 146
 		}
147 147
 		return $this->p( $this->args['description'], ['class' => 'description'] );
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	protected function buildFormInput()
154 154
 	{
155
-		if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) {
155
+		if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) {
156 156
 			return $this->buildFormLabel().$this->getOpeningTag();
157 157
 		}
158
-		return empty( $this->args['options'] )
158
+		return empty($this->args['options'])
159 159
 			? $this->buildFormInputChoice()
160 160
 			: $this->buildFormInputMultiChoice();
161 161
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	protected function buildFormInputMultiChoice()
175 175
 	{
176 176
 		if( $this->args['type'] == 'checkbox' ) {
177
-			$this->args['name'].= '[]';
177
+			$this->args['name'] .= '[]';
178 178
 		}
179 179
 		$options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
180 180
 			return $carry.$this->li( $this->{$this->args['type']}([
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
 				'name' => $this->args['name'],
183 183
 				'text' => $this->args['options'][$key],
184 184
 				'value' => $key,
185
-			]));
185
+			]) );
186 186
 		});
187 187
 		return $this->ul( $options, [
188 188
 			'class' => $this->args['class'],
189 189
 			'id' => $this->args['id'],
190
-		]);
190
+		] );
191 191
 	}
192 192
 
193 193
 	/**
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	protected function buildFormLabel()
197 197
 	{
198
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
199
-		return $this->label([
198
+		if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return;
199
+		return $this->label( [
200 200
 			'for' => $this->args['id'],
201 201
 			'text' => $this->args['label'],
202
-		]);
202
+		] );
203 203
 	}
204 204
 
205 205
 	/**
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	protected function buildFormSelectOptions()
217 217
 	{
218 218
 		return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
219
-			return $carry.$this->option([
219
+			return $carry.$this->option( [
220 220
 				'selected' => $this->args['value'] == $key,
221 221
 				'text' => $this->args['options'][$key],
222 222
 				'value' => $key,
223
-			]);
223
+			] );
224 224
 		});
225 225
 	}
226 226
 
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	protected function buildTag()
239 239
 	{
240
-		if( in_array( $this->tag, static::TAGS_SINGLE )) {
240
+		if( in_array( $this->tag, static::TAGS_SINGLE ) ) {
241 241
 			return $this->getOpeningTag();
242 242
 		}
243
-		if( !in_array( $this->tag, static::TAGS_FORM )) {
243
+		if( !in_array( $this->tag, static::TAGS_FORM ) ) {
244 244
 			return $this->buildDefaultTag();
245 245
 		}
246 246
 		return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	{
262 262
 		$args = glsr( BuilderDefaults::class )->merge( $this->args );
263 263
 		$className = $this->getCustomFieldClassName();
264
-		if( class_exists( $className )) {
264
+		if( class_exists( $className ) ) {
265 265
 			$args = array_merge( $args, $className::defaults() );
266 266
 		}
267 267
 		$this->args = $args;
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	protected function normalize( ...$params )
275 275
 	{
276
-		if( is_string( $params[0] ) || is_numeric( $params[0] )) {
276
+		if( is_string( $params[0] ) || is_numeric( $params[0] ) ) {
277 277
 			$this->setNameOrTextAttributeForTag( $params[0] );
278 278
 		}
279
-		if( is_array( $params[0] )) {
279
+		if( is_array( $params[0] ) ) {
280 280
 			$this->args += $params[0];
281 281
 		}
282
-		else if( is_array( $params[1] )) {
282
+		else if( is_array( $params[1] ) ) {
283 283
 			$this->args += $params[1];
284 284
 		}
285 285
 		$this->mergeArgsWithRequiredDefaults();
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	protected function setTagFromMethod( $method )
305 305
 	{
306 306
 		$this->tag = strtolower( $method );
307
-		if( in_array( $this->tag, static::INPUT_TYPES )) {
307
+		if( in_array( $this->tag, static::INPUT_TYPES ) ) {
308 308
 			$this->args['type'] = $this->tag;
309 309
 			$this->tag = 'input';
310 310
 		}
Please login to merge, or discard this patch.