@@ -11,15 +11,15 @@ |
||
11 | 11 | /** |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function render( array $defaults = [] ) |
|
14 | + public function render(array $defaults = []) |
|
15 | 15 | { |
16 | - $defaults = wp_parse_args( $defaults, [ |
|
16 | + $defaults = wp_parse_args($defaults, [ |
|
17 | 17 | 'type' => 'select', |
18 | 18 | ]); |
19 | 19 | |
20 | - return sprintf( '<select %s>%s</select>%s', |
|
21 | - $this->implodeAttributes( $defaults ), |
|
22 | - $this->implodeOptions( 'select_option' ), |
|
20 | + return sprintf('<select %s>%s</select>%s', |
|
21 | + $this->implodeAttributes($defaults), |
|
22 | + $this->implodeOptions('select_option'), |
|
23 | 23 | $this->generateDescription() |
24 | 24 | ); |
25 | 25 | } |
@@ -11,16 +11,16 @@ |
||
11 | 11 | */ |
12 | 12 | public function render() |
13 | 13 | { |
14 | - if( isset( $this->args['label'] )) { |
|
15 | - unset( $this->args['label'] ); |
|
14 | + if (isset($this->args['label'])) { |
|
15 | + unset($this->args['label']); |
|
16 | 16 | } |
17 | 17 | |
18 | - if( isset( $this->args['desc'] )) { |
|
19 | - unset( $this->args['desc'] ); |
|
18 | + if (isset($this->args['desc'])) { |
|
19 | + unset($this->args['desc']); |
|
20 | 20 | } |
21 | 21 | |
22 | - if( isset( $this->args['id'] )) { |
|
23 | - unset( $this->args['id'] ); |
|
22 | + if (isset($this->args['id'])) { |
|
23 | + unset($this->args['id']); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | return parent::render([ |
@@ -11,16 +11,16 @@ |
||
11 | 11 | /** |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function render( array $defaults = [] ) |
|
14 | + public function render(array $defaults = []) |
|
15 | 15 | { |
16 | - $defaults = wp_parse_args( $defaults, [ |
|
16 | + $defaults = wp_parse_args($defaults, [ |
|
17 | 17 | 'class' => 'large-text', |
18 | 18 | 'rows' => 3, |
19 | 19 | 'type' => 'textarea', |
20 | 20 | ]); |
21 | 21 | |
22 | - return sprintf( '<textarea %s>%s</textarea>%s', |
|
23 | - $this->implodeAttributes( $defaults ), |
|
22 | + return sprintf('<textarea %s>%s</textarea>%s', |
|
23 | + $this->implodeAttributes($defaults), |
|
24 | 24 | $this->args['value'], |
25 | 25 | $this->generateDescription() |
26 | 26 | ); |
@@ -72,7 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function generateDescription( $paragraph = true ) |
74 | 74 | { |
75 | - if( !isset( $this->args['desc'] ) || !$this->args['desc'] )return; |
|
75 | + if( !isset( $this->args['desc'] ) || !$this->args['desc'] ) { |
|
76 | + return; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | $tag = ( !!$paragraph || $paragraph == 'p' ) ? 'p' : 'span'; |
78 | 80 | |
@@ -86,7 +88,9 @@ discard block |
||
86 | 88 | */ |
87 | 89 | public function generateLabel() |
88 | 90 | { |
89 | - if( empty( $this->args['label'] ))return; |
|
91 | + if( empty( $this->args['label'] )) { |
|
92 | + return; |
|
93 | + } |
|
90 | 94 | |
91 | 95 | $for = !!$this->args['id'] |
92 | 96 | ? " for=\"{$this->args['id']}\"" |
@@ -145,7 +149,9 @@ discard block |
||
145 | 149 | |
146 | 150 | if( $method === 'singleInput' ) { |
147 | 151 | |
148 | - if( !isset( $this->args['options'] ) || empty( $this->args['options'] ))return; |
|
152 | + if( !isset( $this->args['options'] ) || empty( $this->args['options'] )) { |
|
153 | + return; |
|
154 | + } |
|
149 | 155 | |
150 | 156 | // hack to make sure unset single checkbox values start at 1 instead of 0 |
151 | 157 | if( key( $this->args['options'] ) === 0 ) { |
@@ -188,7 +194,9 @@ discard block |
||
188 | 194 | { |
189 | 195 | // similar to array_merge except overwrite empty values |
190 | 196 | foreach( $defaults as $key => $value ) { |
191 | - if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue; |
|
197 | + if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] )) { |
|
198 | + continue; |
|
199 | + } |
|
192 | 200 | $this->args[ $key ] = $value; |
193 | 201 | } |
194 | 202 | |
@@ -211,7 +219,9 @@ discard block |
||
211 | 219 | { |
212 | 220 | $args = $this->multiInputArgs( $type, $optionKey, $number ); |
213 | 221 | |
214 | - if( !$args )return; |
|
222 | + if( !$args ) { |
|
223 | + return; |
|
224 | + } |
|
215 | 225 | |
216 | 226 | $attributes = ''; |
217 | 227 | |
@@ -262,7 +272,9 @@ discard block |
||
262 | 272 | |
263 | 273 | $args = wp_parse_args( $args, $defaults ); |
264 | 274 | |
265 | - if( !isset( $label ) || $args['name'] === '' )return; |
|
275 | + if( !isset( $label ) || $args['name'] === '' ) { |
|
276 | + return; |
|
277 | + } |
|
266 | 278 | |
267 | 279 | $args['id'] = $this->args['id'] . "-{$number}"; |
268 | 280 | $args['name'] = $this->args['name'] . ( $type === 'checkbox' && $this->multi ? '[]' : '' ); |
@@ -275,11 +287,9 @@ discard block |
||
275 | 287 | if( in_array( $args['value'], $this->args['value'] )) { |
276 | 288 | $this->args['default'] = $args['value']; |
277 | 289 | } |
278 | - } |
|
279 | - else if( $this->args['value'] ) { |
|
290 | + } else if( $this->args['value'] ) { |
|
280 | 291 | $this->args['default'] = $this->args['value']; |
281 | - } |
|
282 | - else if( $type == 'radio' && !$this->args['default'] ) { |
|
292 | + } else if( $type == 'radio' && !$this->args['default'] ) { |
|
283 | 293 | $this->args['default'] = 0; |
284 | 294 | } |
285 | 295 | |
@@ -332,7 +342,9 @@ discard block |
||
332 | 342 | |
333 | 343 | $args = $this->multiInputArgs( $type, $optionKey, 1 ); |
334 | 344 | |
335 | - if( !$args )return; |
|
345 | + if( !$args ) { |
|
346 | + return; |
|
347 | + } |
|
336 | 348 | |
337 | 349 | $atts = $this->normalize(); |
338 | 350 | $atts = wp_parse_args( $args['attributes'], $atts ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected $element; |
40 | 40 | |
41 | - public function __construct( array $args = [] ) |
|
41 | + public function __construct(array $args = []) |
|
42 | 42 | { |
43 | 43 | $this->args = $args; |
44 | 44 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @return mixed |
50 | 50 | * @throws Exception |
51 | 51 | */ |
52 | - public function __get( $property ) |
|
52 | + public function __get($property) |
|
53 | 53 | { |
54 | - switch( $property ) { |
|
54 | + switch ($property) { |
|
55 | 55 | case 'args': |
56 | 56 | case 'dependencies': |
57 | 57 | case 'element': |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | case 'outside': |
60 | 60 | return $this->$property; |
61 | 61 | } |
62 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
62 | + throw new Exception(sprintf('Invalid %s property: %s', __CLASS__, $property)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return null|string |
71 | 71 | */ |
72 | - public function generateDescription( $paragraph = true ) |
|
72 | + public function generateDescription($paragraph = true) |
|
73 | 73 | { |
74 | - if( !isset( $this->args['desc'] ) || !$this->args['desc'] )return; |
|
74 | + if (!isset($this->args['desc']) || !$this->args['desc'])return; |
|
75 | 75 | |
76 | - $tag = ( !!$paragraph || $paragraph == 'p' ) ? 'p' : 'span'; |
|
76 | + $tag = (!!$paragraph || $paragraph == 'p') ? 'p' : 'span'; |
|
77 | 77 | |
78 | - return sprintf( '<%1$s class="description">%2$s</%1$s>', $tag, $this->args['desc'] ); |
|
78 | + return sprintf('<%1$s class="description">%2$s</%1$s>', $tag, $this->args['desc']); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function generateLabel() |
87 | 87 | { |
88 | - if( empty( $this->args['label'] ))return; |
|
88 | + if (empty($this->args['label']))return; |
|
89 | 89 | |
90 | 90 | $for = !!$this->args['id'] |
91 | 91 | ? " for=\"{$this->args['id']}\"" |
92 | 92 | : ''; |
93 | 93 | |
94 | - return sprintf( '<label%s>%s</label>', $for, $this->args['label'] ); |
|
94 | + return sprintf('<label%s>%s</label>', $for, $this->args['label']); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - protected function camelCase( $value ) |
|
111 | + protected function camelCase($value) |
|
112 | 112 | { |
113 | - $value = ucwords( str_replace( ['-', '_'], ' ', $value )); |
|
113 | + $value = ucwords(str_replace(['-', '_'], ' ', $value)); |
|
114 | 114 | |
115 | - return lcfirst( str_replace( ' ', '', $value )); |
|
115 | + return lcfirst(str_replace(' ', '', $value)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - protected function implodeAttributes( $defaults = [] ) |
|
123 | + protected function implodeAttributes($defaults = []) |
|
124 | 124 | { |
125 | - return $this->normalize( $defaults, 'implode' ); |
|
125 | + return $this->normalize($defaults, 'implode'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,24 +130,24 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return null|string |
132 | 132 | */ |
133 | - protected function implodeOptions( $method = 'select_option', $default = null ) |
|
133 | + protected function implodeOptions($method = 'select_option', $default = null) |
|
134 | 134 | { |
135 | 135 | $this->args['default'] ?: $this->args['default'] = $default; |
136 | 136 | |
137 | - $method = $this->camelCase( $method ); |
|
137 | + $method = $this->camelCase($method); |
|
138 | 138 | |
139 | - $method = method_exists( $this, $method ) |
|
139 | + $method = method_exists($this, $method) |
|
140 | 140 | ? $method |
141 | 141 | : 'selectOption'; |
142 | 142 | |
143 | 143 | $i = 0; |
144 | 144 | |
145 | - if( $method === 'singleInput' ) { |
|
145 | + if ($method === 'singleInput') { |
|
146 | 146 | |
147 | - if( !isset( $this->args['options'] ) || empty( $this->args['options'] ))return; |
|
147 | + if (!isset($this->args['options']) || empty($this->args['options']))return; |
|
148 | 148 | |
149 | 149 | // hack to make sure unset single checkbox values start at 1 instead of 0 |
150 | - if( key( $this->args['options'] ) === 0 ) { |
|
150 | + if (key($this->args['options']) === 0) { |
|
151 | 151 | $options = ['1' => $this->args['options'][0]]; |
152 | 152 | $this->args['options'] = $options; |
153 | 153 | } |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | return $this->singleInput(); |
156 | 156 | } |
157 | 157 | |
158 | - return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use ( &$i, $method ) { |
|
159 | - return $carry .= $this->$method( $key, $i++ ); |
|
158 | + return array_reduce(array_keys($this->args['options']), function($carry, $key) use (&$i, $method) { |
|
159 | + return $carry .= $this->$method($key, $i++); |
|
160 | 160 | }); |
161 | 161 | } |
162 | 162 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return array |
169 | 169 | */ |
170 | - protected function normalize( array $defaults = [], $implode = false ) |
|
170 | + protected function normalize(array $defaults = [], $implode = false) |
|
171 | 171 | { |
172 | - $args = $this->mergeAttributesWith( $defaults ); |
|
172 | + $args = $this->mergeAttributesWith($defaults); |
|
173 | 173 | |
174 | 174 | $normalize = new Normalize; |
175 | 175 | |
176 | - return ( $this->element && method_exists( $normalize, $this->element )) |
|
177 | - ? $normalize->{$this->element}( $args, $implode ) |
|
178 | - : ( !!$implode ? '' : [] ); |
|
176 | + return ($this->element && method_exists($normalize, $this->element)) |
|
177 | + ? $normalize->{$this->element}($args, $implode) |
|
178 | + : (!!$implode ? '' : []); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return array |
185 | 185 | */ |
186 | - protected function mergeAttributesWith( array $defaults ) |
|
186 | + protected function mergeAttributesWith(array $defaults) |
|
187 | 187 | { |
188 | 188 | // similar to array_merge except overwrite empty values |
189 | - foreach( $defaults as $key => $value ) { |
|
190 | - if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue; |
|
191 | - $this->args[ $key ] = $value; |
|
189 | + foreach ($defaults as $key => $value) { |
|
190 | + if (isset($this->args[$key]) && !empty($this->args[$key]))continue; |
|
191 | + $this->args[$key] = $value; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $attributes = $this->args['attributes']; |
195 | 195 | |
196 | 196 | // prioritize $attributes over $this->args, don't worry about duplicates |
197 | - return array_merge( $this->args, $attributes ); |
|
197 | + return array_merge($this->args, $attributes); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return null|string |
208 | 208 | */ |
209 | - protected function multiInput( $optionKey, $number, $type = 'radio' ) |
|
209 | + protected function multiInput($optionKey, $number, $type = 'radio') |
|
210 | 210 | { |
211 | - $args = $this->multiInputArgs( $type, $optionKey, $number ); |
|
211 | + $args = $this->multiInputArgs($type, $optionKey, $number); |
|
212 | 212 | |
213 | - if( !$args )return; |
|
213 | + if (!$args)return; |
|
214 | 214 | |
215 | 215 | $attributes = ''; |
216 | 216 | |
217 | - foreach( $args['attributes'] as $key => $val ) { |
|
218 | - $attributes .= sprintf( '%s="%s" ', $key, $val ); |
|
217 | + foreach ($args['attributes'] as $key => $val) { |
|
218 | + $attributes .= sprintf('%s="%s" ', $key, $val); |
|
219 | 219 | } |
220 | 220 | |
221 | - return sprintf( '<li><label for="%s"><input %s%s/> %s</label></li>', |
|
221 | + return sprintf('<li><label for="%s"><input %s%s/> %s</label></li>', |
|
222 | 222 | $args['attributes']['id'], |
223 | 223 | $attributes, |
224 | - checked( $args['value'], $args['attributes']['value'], false ), |
|
224 | + checked($args['value'], $args['attributes']['value'], false), |
|
225 | 225 | $args['label'] |
226 | 226 | ); |
227 | 227 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return array|null |
237 | 237 | */ |
238 | - protected function multiInputArgs( $type, $optionName, $number ) |
|
238 | + protected function multiInputArgs($type, $optionName, $number) |
|
239 | 239 | { |
240 | 240 | $defaults = [ |
241 | 241 | 'class' => '', |
@@ -246,39 +246,39 @@ discard block |
||
246 | 246 | |
247 | 247 | $args = []; |
248 | 248 | |
249 | - $value = $this->args['options'][ $optionName ]; |
|
249 | + $value = $this->args['options'][$optionName]; |
|
250 | 250 | |
251 | - if( is_array( $value )) { |
|
251 | + if (is_array($value)) { |
|
252 | 252 | $args = $value; |
253 | 253 | } |
254 | 254 | |
255 | - if( is_string( $value )) { |
|
255 | + if (is_string($value)) { |
|
256 | 256 | $label = $value; |
257 | 257 | } |
258 | 258 | |
259 | - isset( $args['name'] ) ?: $args['name'] = $optionName; |
|
260 | - isset( $args['value'] ) ?: $args['value'] = $optionName; |
|
259 | + isset($args['name']) ?: $args['name'] = $optionName; |
|
260 | + isset($args['value']) ?: $args['value'] = $optionName; |
|
261 | 261 | |
262 | - $args = wp_parse_args( $args, $defaults ); |
|
262 | + $args = wp_parse_args($args, $defaults); |
|
263 | 263 | |
264 | - if( !isset( $label ) || $args['name'] === '' )return; |
|
264 | + if (!isset($label) || $args['name'] === '')return; |
|
265 | 265 | |
266 | 266 | $args['id'] = $this->args['id'] . "-{$number}"; |
267 | - $args['name'] = $this->args['name'] . ( $type === 'checkbox' && $this->multi ? '[]' : '' ); |
|
267 | + $args['name'] = $this->args['name'] . ($type === 'checkbox' && $this->multi ? '[]' : ''); |
|
268 | 268 | |
269 | - $args = array_filter( $args, function( $value ) { |
|
269 | + $args = array_filter($args, function($value) { |
|
270 | 270 | return $value !== ''; |
271 | 271 | }); |
272 | 272 | |
273 | - if( is_array( $this->args['value'] )) { |
|
274 | - if( in_array( $args['value'], $this->args['value'] )) { |
|
273 | + if (is_array($this->args['value'])) { |
|
274 | + if (in_array($args['value'], $this->args['value'])) { |
|
275 | 275 | $this->args['default'] = $args['value']; |
276 | 276 | } |
277 | 277 | } |
278 | - else if( $this->args['value'] ) { |
|
278 | + else if ($this->args['value']) { |
|
279 | 279 | $this->args['default'] = $this->args['value']; |
280 | 280 | } |
281 | - else if( $type == 'radio' && !$this->args['default'] ) { |
|
281 | + else if ($type == 'radio' && !$this->args['default']) { |
|
282 | 282 | $this->args['default'] = 0; |
283 | 283 | } |
284 | 284 | |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return null|string |
299 | 299 | */ |
300 | - protected function multiInputCheckbox( $optionKey, $number ) |
|
300 | + protected function multiInputCheckbox($optionKey, $number) |
|
301 | 301 | { |
302 | - return $this->multiInput( $optionKey, $number, 'checkbox' ); |
|
302 | + return $this->multiInput($optionKey, $number, 'checkbox'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -309,12 +309,12 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - protected function selectOption( $optionKey ) |
|
312 | + protected function selectOption($optionKey) |
|
313 | 313 | { |
314 | - return sprintf( '<option value="%s"%s>%s</option>', |
|
314 | + return sprintf('<option value="%s"%s>%s</option>', |
|
315 | 315 | $optionKey, |
316 | - selected( $this->args['value'], $optionKey, false ), |
|
317 | - $this->args['options'][ $optionKey ] |
|
316 | + selected($this->args['value'], $optionKey, false), |
|
317 | + $this->args['options'][$optionKey] |
|
318 | 318 | ); |
319 | 319 | } |
320 | 320 | |
@@ -325,27 +325,27 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @return null|string |
327 | 327 | */ |
328 | - protected function singleInput( $type = 'checkbox' ) |
|
328 | + protected function singleInput($type = 'checkbox') |
|
329 | 329 | { |
330 | - $optionKey = key( $this->args['options'] ); |
|
330 | + $optionKey = key($this->args['options']); |
|
331 | 331 | |
332 | - $args = $this->multiInputArgs( $type, $optionKey, 1 ); |
|
332 | + $args = $this->multiInputArgs($type, $optionKey, 1); |
|
333 | 333 | |
334 | - if( !$args )return; |
|
334 | + if (!$args)return; |
|
335 | 335 | |
336 | 336 | $atts = $this->normalize(); |
337 | - $atts = wp_parse_args( $args['attributes'], $atts ); |
|
337 | + $atts = wp_parse_args($args['attributes'], $atts); |
|
338 | 338 | |
339 | 339 | $attributes = ''; |
340 | 340 | |
341 | - foreach( $atts as $key => $val ) { |
|
342 | - $attributes .= sprintf( '%s="%s" ', $key, $val ); |
|
341 | + foreach ($atts as $key => $val) { |
|
342 | + $attributes .= sprintf('%s="%s" ', $key, $val); |
|
343 | 343 | } |
344 | 344 | |
345 | - return sprintf( '<label for="%s"><input %s%s/> %s</label>', |
|
345 | + return sprintf('<label for="%s"><input %s%s/> %s</label>', |
|
346 | 346 | $atts['id'], |
347 | 347 | $attributes, |
348 | - checked( $args['value'], $atts['value'], false ), |
|
348 | + checked($args['value'], $atts['value'], false), |
|
349 | 349 | $args['label'] |
350 | 350 | ); |
351 | 351 | } |
@@ -11,15 +11,15 @@ |
||
11 | 11 | /** |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function render( array $defaults = [] ) |
|
14 | + public function render(array $defaults = []) |
|
15 | 15 | { |
16 | - $defaults = wp_parse_args( $defaults, [ |
|
16 | + $defaults = wp_parse_args($defaults, [ |
|
17 | 17 | 'class' => 'regular-text', |
18 | 18 | 'type' => 'text', |
19 | 19 | ]); |
20 | 20 | |
21 | - return sprintf( '<input %s/>%s', |
|
22 | - $this->implodeAttributes( $defaults ), |
|
21 | + return sprintf('<input %s/>%s', |
|
22 | + $this->implodeAttributes($defaults), |
|
23 | 23 | $this->generateDescription() |
24 | 24 | ); |
25 | 25 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected $normalize; |
35 | 35 | |
36 | - public function __construct( Field $field, Normalizer $normalize ) |
|
36 | + public function __construct(Field $field, Normalizer $normalize) |
|
37 | 37 | { |
38 | 38 | $this->args = []; |
39 | 39 | $this->dependencies = []; |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | * @return mixed |
49 | 49 | * @throws Exception |
50 | 50 | */ |
51 | - public function __get( $property ) |
|
51 | + public function __get($property) |
|
52 | 52 | { |
53 | - switch( $property ) { |
|
53 | + switch ($property) { |
|
54 | 54 | case 'args': |
55 | 55 | case 'dependencies': |
56 | 56 | case 'fields': |
57 | 57 | return $this->$property; |
58 | 58 | } |
59 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
59 | + throw new Exception(sprintf('Invalid %s property: %s', __CLASS__, $property)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | * @throws Exception |
68 | 68 | */ |
69 | - public function __set( $property, $value ) |
|
69 | + public function __set($property, $value) |
|
70 | 70 | { |
71 | - switch( $property ) { |
|
71 | + switch ($property) { |
|
72 | 72 | case 'args': |
73 | 73 | case 'dependencies': |
74 | 74 | case 'fields': |
75 | 75 | $this->$property = $value; |
76 | 76 | break; |
77 | 77 | default: |
78 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
78 | + throw new Exception(sprintf('Invalid %s property: %s', __CLASS__, $property)); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return Form |
86 | 86 | */ |
87 | - public function addField( array $args = [] ) |
|
87 | + public function addField(array $args = []) |
|
88 | 88 | { |
89 | - $field = $this->field->normalize( $args ); |
|
89 | + $field = $this->field->normalize($args); |
|
90 | 90 | |
91 | - if( $field->args['render'] !== false ) { |
|
91 | + if ($field->args['render'] !== false) { |
|
92 | 92 | $this->dependencies = array_unique( |
93 | - array_merge( $field->dependencies, $this->dependencies ) |
|
93 | + array_merge($field->dependencies, $this->dependencies) |
|
94 | 94 | ); |
95 | 95 | $this->fields[] = $field; |
96 | 96 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return Form |
105 | 105 | */ |
106 | - public function normalize( array $args = [] ) |
|
106 | + public function normalize(array $args = []) |
|
107 | 107 | { |
108 | 108 | $defaults = [ |
109 | 109 | 'action' => '', |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | 'enctype' => 'multipart/form-data', |
114 | 114 | 'method' => 'post', |
115 | 115 | 'nonce' => '', |
116 | - 'submit' => __( 'Submit', 'site-reviews' ), |
|
116 | + 'submit' => __('Submit', 'site-reviews'), |
|
117 | 117 | ]; |
118 | 118 | |
119 | - $this->args = array_merge( $defaults, $args ); |
|
119 | + $this->args = array_merge($defaults, $args); |
|
120 | 120 | |
121 | - $attributes = $this->normalize->form( $this->args, 'implode' ); |
|
121 | + $attributes = $this->normalize->form($this->args, 'implode'); |
|
122 | 122 | |
123 | 123 | $this->args['attributes'] = $attributes; |
124 | 124 | |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return string|void |
134 | 134 | */ |
135 | - public function render( $print = true ) |
|
135 | + public function render($print = true) |
|
136 | 136 | { |
137 | - $rendered = sprintf( '<form %s>%s%s</form>', |
|
137 | + $rendered = sprintf('<form %s>%s%s</form>', |
|
138 | 138 | $this->args['attributes'], |
139 | 139 | $this->generateFields(), |
140 | 140 | $this->generateSubmitButton() |
141 | 141 | ); |
142 | 142 | |
143 | - if( !!$print && $print !== 'return' ) { |
|
143 | + if (!!$print && $print !== 'return') { |
|
144 | 144 | echo $rendered; |
145 | 145 | } |
146 | 146 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | $hiddenFields = ''; |
171 | 171 | |
172 | - $fields = array_reduce( $this->fields, function( $carry, $formField ) use ( &$hiddenFields ) { |
|
172 | + $fields = array_reduce($this->fields, function($carry, $formField) use (&$hiddenFields) { |
|
173 | 173 | |
174 | 174 | $stringLegend = '<legend class="screen-reader-text"><span>%s</span></legend>'; |
175 | 175 | $stringFieldset = '<fieldset%s>%s%s</fieldset>'; |
@@ -185,30 +185,30 @@ discard block |
||
185 | 185 | $rendered = $field->render(); |
186 | 186 | |
187 | 187 | // render hidden inputs outside the table |
188 | - if( $field->args['type'] === 'hidden' ) { |
|
188 | + if ($field->args['type'] === 'hidden') { |
|
189 | 189 | $hiddenFields .= $rendered; |
190 | 190 | return $carry; |
191 | 191 | } |
192 | 192 | |
193 | - $hiddenClass = $this->isFieldHidden( $formField ) ? 'hidden' : ''; |
|
193 | + $hiddenClass = $this->isFieldHidden($formField) ? 'hidden' : ''; |
|
194 | 194 | |
195 | - if( $multi ) { |
|
196 | - if( $depends = $formField->getDataDepends() ) { |
|
197 | - $depends = sprintf( ' data-depends=\'%s\'', json_encode( $depends )); |
|
195 | + if ($multi) { |
|
196 | + if ($depends = $formField->getDataDepends()) { |
|
197 | + $depends = sprintf(' data-depends=\'%s\'', json_encode($depends)); |
|
198 | 198 | } |
199 | 199 | |
200 | - $legend = $label ? sprintf( $stringLegend, $label ) : ''; |
|
201 | - $rendered = sprintf( $stringFieldset, $depends, $legend, $rendered ); |
|
200 | + $legend = $label ? sprintf($stringLegend, $label) : ''; |
|
201 | + $rendered = sprintf($stringFieldset, $depends, $legend, $rendered); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $renderedField = $field->outside |
205 | - ? sprintf( $outsideRendered, $rendered ) |
|
206 | - : sprintf( $stringRendered, $hiddenClass, $label, $rendered ); |
|
205 | + ? sprintf($outsideRendered, $rendered) |
|
206 | + : sprintf($stringRendered, $hiddenClass, $label, $rendered); |
|
207 | 207 | |
208 | 208 | return $carry . $renderedField; |
209 | 209 | }); |
210 | 210 | |
211 | - return sprintf( '<table class="form-table"><tbody>%s</tbody></table>%s', $fields, $hiddenFields ); |
|
211 | + return sprintf('<table class="form-table"><tbody>%s</tbody></table>%s', $fields, $hiddenFields); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -220,19 +220,19 @@ discard block |
||
220 | 220 | { |
221 | 221 | $args = $this->args['submit']; |
222 | 222 | |
223 | - is_array( $args ) ?: $args = ['text' => $args ]; |
|
223 | + is_array($args) ?: $args = ['text' => $args]; |
|
224 | 224 | |
225 | 225 | $args = shortcode_atts([ |
226 | - 'text' => __( 'Save Changes', 'site-reviews' ), |
|
226 | + 'text' => __('Save Changes', 'site-reviews'), |
|
227 | 227 | 'type' => 'primary', |
228 | 228 | 'name' => 'submit', |
229 | 229 | 'wrap' => true, |
230 | 230 | 'other_attributes' => null, |
231 | - ], $args ); |
|
231 | + ], $args); |
|
232 | 232 | |
233 | - if( is_admin() ) { |
|
233 | + if (is_admin()) { |
|
234 | 234 | ob_start(); |
235 | - submit_button( $args['text'], $args['type'], $args['name'], $args['wrap'], $args['other_attributes'] ); |
|
235 | + submit_button($args['text'], $args['type'], $args['name'], $args['wrap'], $args['other_attributes']); |
|
236 | 236 | return ob_get_clean(); |
237 | 237 | } |
238 | 238 | } |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return bool|null |
244 | 244 | */ |
245 | - protected function isFieldHidden( $field ) |
|
245 | + protected function isFieldHidden($field) |
|
246 | 246 | { |
247 | - if( !( $dependsOn = $field->getDataDepends() ))return; |
|
247 | + if (!($dependsOn = $field->getDataDepends()))return; |
|
248 | 248 | |
249 | - foreach( $this->fields as $formField ) { |
|
250 | - if( $dependsOn['name'] !== $formField->args['name'] )continue; |
|
249 | + foreach ($this->fields as $formField) { |
|
250 | + if ($dependsOn['name'] !== $formField->args['name'])continue; |
|
251 | 251 | |
252 | - if( is_array( $dependsOn['value'] )) { |
|
253 | - return !in_array( $formField->args['value'], $dependsOn['value'] ); |
|
252 | + if (is_array($dependsOn['value'])) { |
|
253 | + return !in_array($formField->args['value'], $dependsOn['value']); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | return $dependsOn['value'] != $formField->args['value']; |
@@ -244,10 +244,14 @@ |
||
244 | 244 | */ |
245 | 245 | protected function isFieldHidden( $field ) |
246 | 246 | { |
247 | - if( !( $dependsOn = $field->getDataDepends() ))return; |
|
247 | + if( !( $dependsOn = $field->getDataDepends() )) { |
|
248 | + return; |
|
249 | + } |
|
248 | 250 | |
249 | 251 | foreach( $this->fields as $formField ) { |
250 | - if( $dependsOn['name'] !== $formField->args['name'] )continue; |
|
252 | + if( $dependsOn['name'] !== $formField->args['name'] ) { |
|
253 | + continue; |
|
254 | + } |
|
251 | 255 | |
252 | 256 | if( is_array( $dependsOn['value'] )) { |
253 | 257 | return !in_array( $formField->args['value'], $dependsOn['value'] ); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * @return mixed |
27 | 27 | * @throws Exception |
28 | 28 | */ |
29 | - public function __get( $property ) |
|
29 | + public function __get($property) |
|
30 | 30 | { |
31 | - switch( $property ) { |
|
31 | + switch ($property) { |
|
32 | 32 | case 'args': |
33 | 33 | case 'dependencies': |
34 | 34 | return $this->$property; |
35 | 35 | } |
36 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
36 | + throw new Exception(sprintf('Invalid %s property: %s', __CLASS__, $property)); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed GeminiLabs\SiteReviews\Html\Fields\* |
44 | 44 | */ |
45 | - public function getField( array $args = [] ) |
|
45 | + public function getField(array $args = []) |
|
46 | 46 | { |
47 | - if( empty( $args )) { |
|
47 | + if (empty($args)) { |
|
48 | 48 | $args = $this->args; |
49 | 49 | } |
50 | 50 | |
51 | - $className = sprintf( 'GeminiLabs\Castor\Forms\Fields\%s', ucfirst( $args['type'] )); |
|
51 | + $className = sprintf('GeminiLabs\Castor\Forms\Fields\%s', ucfirst($args['type'])); |
|
52 | 52 | |
53 | - if( !class_exists( $className )) { |
|
54 | - throw new ReflectionException( "Class does not exist: {$className}" ); |
|
53 | + if (!class_exists($className)) { |
|
54 | + throw new ReflectionException("Class does not exist: {$className}"); |
|
55 | 55 | } |
56 | 56 | |
57 | - return (new $className( $args )); |
|
57 | + return (new $className($args)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return $this |
64 | 64 | */ |
65 | - public function normalize( array $args = [] ) |
|
65 | + public function normalize(array $args = []) |
|
66 | 66 | { |
67 | 67 | $defaults = [ |
68 | 68 | 'after' => '', |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | 'value' => '', |
87 | 87 | ]; |
88 | 88 | |
89 | - $args = $atts = wp_parse_args( $args, $defaults ); |
|
89 | + $args = $atts = wp_parse_args($args, $defaults); |
|
90 | 90 | |
91 | - $args['attributes'] = $this->parseAttributes( $atts ); |
|
92 | - $args['id'] = $this->parseId( $atts ); |
|
93 | - $args['inline'] = $this->parseInline( $atts ); |
|
94 | - $args['type'] = $this->parseType( $atts ); |
|
95 | - $args['name'] = $this->parseName( $atts ); |
|
91 | + $args['attributes'] = $this->parseAttributes($atts); |
|
92 | + $args['id'] = $this->parseId($atts); |
|
93 | + $args['inline'] = $this->parseInline($atts); |
|
94 | + $args['type'] = $this->parseType($atts); |
|
95 | + $args['name'] = $this->parseName($atts); |
|
96 | 96 | $args['options'] = (array) $atts['options']; // make sure this is always an array |
97 | 97 | $args['path'] = $atts['name']; |
98 | - $args['prefix'] = $this->parsePrefix( $atts ); |
|
99 | - $args['value'] = $this->parseValue( $atts ); |
|
98 | + $args['prefix'] = $this->parsePrefix($atts); |
|
99 | + $args['value'] = $this->parseValue($atts); |
|
100 | 100 | |
101 | 101 | $this->args = $args; |
102 | - $this->dependencies = $this->getField( $args )->dependencies; |
|
102 | + $this->dependencies = $this->getField($args)->dependencies; |
|
103 | 103 | |
104 | 104 | $this->setDataDepends(); |
105 | - $this->checkForErrors( $atts ); |
|
105 | + $this->checkForErrors($atts); |
|
106 | 106 | |
107 | 107 | return $this; |
108 | 108 | } |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string|void |
116 | 116 | */ |
117 | - public function render( $print = true ) |
|
117 | + public function render($print = true) |
|
118 | 118 | { |
119 | - if( $this->args['render'] === false )return; |
|
119 | + if ($this->args['render'] === false)return; |
|
120 | 120 | |
121 | 121 | $field = $this->getField(); |
122 | 122 | |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | |
126 | 126 | $renderedString = '%s'; |
127 | 127 | |
128 | - if( ( isset( $field->args['required'] ) && $field->args['required'] ) |
|
129 | - || ( isset( $field->args['attributes']['required'] ) || in_array( 'required', $field->args['attributes'] )) ) { |
|
128 | + if ((isset($field->args['required']) && $field->args['required']) |
|
129 | + || (isset($field->args['attributes']['required']) || in_array('required', $field->args['attributes']))) { |
|
130 | 130 | $class .= ' glsr-required'; |
131 | 131 | } |
132 | 132 | |
133 | - if( $field->args['type'] !== 'hidden' ) { |
|
134 | - $renderedString = sprintf( '<div class="%s">%%s</div>', $class ); |
|
133 | + if ($field->args['type'] !== 'hidden') { |
|
134 | + $renderedString = sprintf('<div class="%s">%%s</div>', $class); |
|
135 | 135 | } |
136 | 136 | |
137 | - $rendered = sprintf( $renderedString, |
|
137 | + $rendered = sprintf($renderedString, |
|
138 | 138 | $this->args['before'] . |
139 | 139 | $field->generateLabel() . |
140 | 140 | $field->render() . |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | $this->args['errors'] |
143 | 143 | ); |
144 | 144 | |
145 | - $rendered = apply_filters( 'castor/rendered/field', $rendered, $field->args['type'] ); |
|
145 | + $rendered = apply_filters('castor/rendered/field', $rendered, $field->args['type']); |
|
146 | 146 | |
147 | - if( !!$print && $print !== 'return' ) { |
|
147 | + if (!!$print && $print !== 'return') { |
|
148 | 148 | echo $rendered; |
149 | 149 | } |
150 | 150 | |
@@ -168,22 +168,22 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return void |
170 | 170 | */ |
171 | - protected function checkForErrors( array $atts ) |
|
171 | + protected function checkForErrors(array $atts) |
|
172 | 172 | { |
173 | 173 | $args = $this->args; |
174 | 174 | |
175 | - if( !array_key_exists( $atts['name'], $args['errors'] )) { |
|
175 | + if (!array_key_exists($atts['name'], $args['errors'])) { |
|
176 | 176 | $this->args['errors'] = ''; // set to an empty string |
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | - $field_errors = $args['errors'][ $atts['name'] ]; |
|
180 | + $field_errors = $args['errors'][$atts['name']]; |
|
181 | 181 | |
182 | - $errors = array_reduce( $field_errors['errors'], function( $carry, $error ) { |
|
183 | - return $carry . sprintf( '<span>%s</span> ', $error ); |
|
182 | + $errors = array_reduce($field_errors['errors'], function($carry, $error) { |
|
183 | + return $carry . sprintf('<span>%s</span> ', $error); |
|
184 | 184 | }); |
185 | 185 | |
186 | - $this->args['errors'] = sprintf( '<span class="glsr-field-errors">%s</span>', $errors ); |
|
186 | + $this->args['errors'] = sprintf('<span class="glsr-field-errors">%s</span>', $errors); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array |
193 | 193 | */ |
194 | - protected function parseAttributes( array $args ) |
|
194 | + protected function parseAttributes(array $args) |
|
195 | 195 | { |
196 | - if( empty( $args['attributes'] )) { |
|
196 | + if (empty($args['attributes'])) { |
|
197 | 197 | return []; |
198 | 198 | } |
199 | 199 | |
200 | 200 | $attributes = (array) $args['attributes']; |
201 | 201 | |
202 | - foreach( $attributes as $key => $value ) { |
|
203 | - if( is_string( $key ))continue; |
|
204 | - unset( $attributes[ $key ] ); |
|
205 | - if( !isset( $attributes[ $value ] )) { |
|
206 | - $attributes[ $value ] = ''; |
|
202 | + foreach ($attributes as $key => $value) { |
|
203 | + if (is_string($key))continue; |
|
204 | + unset($attributes[$key]); |
|
205 | + if (!isset($attributes[$value])) { |
|
206 | + $attributes[$value] = ''; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return null|string |
217 | 217 | */ |
218 | - protected function parseId( array $args ) |
|
218 | + protected function parseId(array $args) |
|
219 | 219 | { |
220 | - if( isset( $args['id'] ) && !$args['id'] )return; |
|
220 | + if (isset($args['id']) && !$args['id'])return; |
|
221 | 221 | |
222 | 222 | !$args['suffix'] ?: $args['suffix'] = "-{$args['suffix']}"; |
223 | 223 | |
224 | - return str_replace( ['[]','[',']','.'], ['','-','','-'], $this->parseName( $args ) . $args['suffix'] ); |
|
224 | + return str_replace(['[]', '[', ']', '.'], ['', '-', '', '-'], $this->parseName($args) . $args['suffix']); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return bool |
231 | 231 | */ |
232 | - protected function parseInline( array $args ) |
|
232 | + protected function parseInline(array $args) |
|
233 | 233 | { |
234 | - return false !== stripos( $args['type'], '_inline' ) |
|
234 | + return false !== stripos($args['type'], '_inline') |
|
235 | 235 | ? true |
236 | 236 | : $args['inline']; |
237 | 237 | } |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return string |
243 | 243 | */ |
244 | - protected function parseName( array $args ) |
|
244 | + protected function parseName(array $args) |
|
245 | 245 | { |
246 | 246 | $name = $args['name']; |
247 | - $prefix = $this->parsePrefix( $args ); |
|
247 | + $prefix = $this->parsePrefix($args); |
|
248 | 248 | |
249 | - if( $prefix === false ) { |
|
249 | + if ($prefix === false) { |
|
250 | 250 | return $name; |
251 | 251 | } |
252 | 252 | |
253 | - $paths = explode( '.', $name ); |
|
253 | + $paths = explode('.', $name); |
|
254 | 254 | |
255 | - return array_reduce( $paths, function( $result, $value ) { |
|
255 | + return array_reduce($paths, function($result, $value) { |
|
256 | 256 | return $result .= "[$value]"; |
257 | - }, $prefix ); |
|
257 | + }, $prefix); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return string|false |
264 | 264 | */ |
265 | - protected function parsePrefix( array $args ) |
|
265 | + protected function parsePrefix(array $args) |
|
266 | 266 | { |
267 | 267 | return $args['prefix']; |
268 | 268 | } |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return string |
274 | 274 | */ |
275 | - protected function parseType( array $args ) |
|
275 | + protected function parseType(array $args) |
|
276 | 276 | { |
277 | 277 | $type = $args['type']; |
278 | 278 | |
279 | - return false !== stripos( $type, '_inline' ) |
|
280 | - ? str_replace( '_inline', '', $type ) |
|
279 | + return false !== stripos($type, '_inline') |
|
280 | + ? str_replace('_inline', '', $type) |
|
281 | 281 | : $type; |
282 | 282 | } |
283 | 283 | |
@@ -286,18 +286,18 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - protected function parseValue( array $args ) |
|
289 | + protected function parseValue(array $args) |
|
290 | 290 | { |
291 | 291 | $default = $args['default']; |
292 | 292 | $name = $args['name']; |
293 | 293 | $prefix = $args['prefix']; |
294 | 294 | $value = $args['value']; |
295 | 295 | |
296 | - if( $default == ':placeholder' ) { |
|
296 | + if ($default == ':placeholder') { |
|
297 | 297 | $default = ''; |
298 | 298 | } |
299 | 299 | |
300 | - return ( !empty( $value ) || !$name || $prefix === false ) |
|
300 | + return (!empty($value) || !$name || $prefix === false) |
|
301 | 301 | ? $value |
302 | 302 | : $default; |
303 | 303 | } |
@@ -329,15 +329,15 @@ discard block |
||
329 | 329 | */ |
330 | 330 | protected function setDataDepends() |
331 | 331 | { |
332 | - if( !( $depends = $this->args['depends'] ))return; |
|
332 | + if (!($depends = $this->args['depends']))return; |
|
333 | 333 | |
334 | 334 | $name = $depends; |
335 | 335 | $value = true; |
336 | 336 | |
337 | - if( is_array( $depends )) { |
|
338 | - reset( $depends ); |
|
339 | - $name = key( $depends ); |
|
340 | - $value = $depends[ $name ]; |
|
337 | + if (is_array($depends)) { |
|
338 | + reset($depends); |
|
339 | + $name = key($depends); |
|
340 | + $value = $depends[$name]; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | $name = $this->parseName([ |
@@ -116,7 +116,9 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function render( $print = true ) |
118 | 118 | { |
119 | - if( $this->args['render'] === false )return; |
|
119 | + if( $this->args['render'] === false ) { |
|
120 | + return; |
|
121 | + } |
|
120 | 122 | |
121 | 123 | $field = $this->getField(); |
122 | 124 | |
@@ -200,7 +202,9 @@ discard block |
||
200 | 202 | $attributes = (array) $args['attributes']; |
201 | 203 | |
202 | 204 | foreach( $attributes as $key => $value ) { |
203 | - if( is_string( $key ))continue; |
|
205 | + if( is_string( $key )) { |
|
206 | + continue; |
|
207 | + } |
|
204 | 208 | unset( $attributes[ $key ] ); |
205 | 209 | if( !isset( $attributes[ $value ] )) { |
206 | 210 | $attributes[ $value ] = ''; |
@@ -217,7 +221,9 @@ discard block |
||
217 | 221 | */ |
218 | 222 | protected function parseId( array $args ) |
219 | 223 | { |
220 | - if( isset( $args['id'] ) && !$args['id'] )return; |
|
224 | + if( isset( $args['id'] ) && !$args['id'] ) { |
|
225 | + return; |
|
226 | + } |
|
221 | 227 | |
222 | 228 | !$args['suffix'] ?: $args['suffix'] = "-{$args['suffix']}"; |
223 | 229 | |
@@ -329,7 +335,9 @@ discard block |
||
329 | 335 | */ |
330 | 336 | protected function setDataDepends() |
331 | 337 | { |
332 | - if( !( $depends = $this->args['depends'] ))return; |
|
338 | + if( !( $depends = $this->args['depends'] )) { |
|
339 | + return; |
|
340 | + } |
|
333 | 341 | |
334 | 342 | $name = $depends; |
335 | 343 | $value = true; |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | * @return mixed |
31 | 31 | * @throws \RuntimeException |
32 | 32 | */ |
33 | - public static function __callStatic( $method, $args ) |
|
33 | + public static function __callStatic($method, $args) |
|
34 | 34 | { |
35 | 35 | $instance = static::getFacadeRoot(); |
36 | 36 | |
37 | - if( !$instance ) { |
|
38 | - throw new RuntimeException( 'A facade root has not been set.' ); |
|
37 | + if (!$instance) { |
|
38 | + throw new RuntimeException('A facade root has not been set.'); |
|
39 | 39 | } |
40 | 40 | |
41 | - return $instance->$method( ...$args ); |
|
41 | + return $instance->$method(...$args); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function getFacadeRoot() |
70 | 70 | { |
71 | - return static::resolveFacadeInstance( static::getFacadeAccessor() ); |
|
71 | + return static::resolveFacadeInstance(static::getFacadeAccessor()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return void |
78 | 78 | */ |
79 | - public static function setFacadeApplication( Application $app ) |
|
79 | + public static function setFacadeApplication(Application $app) |
|
80 | 80 | { |
81 | 81 | static::$app = $app; |
82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected static function getFacadeAccessor() |
92 | 92 | { |
93 | - throw new RuntimeException( 'Facade does not implement getFacadeAccessor method.' ); |
|
93 | + throw new RuntimeException('Facade does not implement getFacadeAccessor method.'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return mixed |
102 | 102 | */ |
103 | - protected static function resolveFacadeInstance( $name ) |
|
103 | + protected static function resolveFacadeInstance($name) |
|
104 | 104 | { |
105 | - if( is_object( $name )) { |
|
105 | + if (is_object($name)) { |
|
106 | 106 | return $name; |
107 | 107 | } |
108 | 108 | |
109 | - if( isset( static::$resolvedInstance[$name] )) { |
|
109 | + if (isset(static::$resolvedInstance[$name])) { |
|
110 | 110 | return static::$resolvedInstance[$name]; |
111 | 111 | } |
112 | 112 | |
113 | - return static::$resolvedInstance[$name] = static::$app->make( $name ); |
|
113 | + return static::$resolvedInstance[$name] = static::$app->make($name); |
|
114 | 114 | } |
115 | 115 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class SiteMeta extends Facade |
8 | 8 | { |
9 | - /** |
|
10 | - * Get the fully qualified class name of the component. |
|
11 | - * |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - protected static function getFacadeAccessor() |
|
15 | - { |
|
16 | - return \GeminiLabs\Castor\Helpers\SiteMeta::class; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Get the fully qualified class name of the component. |
|
11 | + * |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + protected static function getFacadeAccessor() |
|
15 | + { |
|
16 | + return \GeminiLabs\Castor\Helpers\SiteMeta::class; |
|
17 | + } |
|
18 | 18 | } |