@@ -33,7 +33,7 @@ discard block |
||
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 | |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | */ |
45 | 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 )) { |
|
53 | + if( !class_exists( $className ) ) { |
|
54 | 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 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $renderedString = '%s'; |
127 | 127 | |
128 | 128 | if( ( isset( $field->args['required'] ) && $field->args['required'] ) |
129 | - || ( isset( $field->args['attributes']['required'] ) || in_array( 'required', $field->args['attributes'] )) ) { |
|
129 | + || ( isset( $field->args['attributes']['required'] ) || in_array( 'required', $field->args['attributes'] ) ) ) { |
|
130 | 130 | $class .= ' glsr-required'; |
131 | 131 | } |
132 | 132 | |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | $rendered = sprintf( $renderedString, |
138 | - $this->args['before'] . |
|
139 | - $field->generateLabel() . |
|
140 | - $field->render() . |
|
141 | - $this->args['after'] . |
|
138 | + $this->args['before']. |
|
139 | + $field->generateLabel(). |
|
140 | + $field->render(). |
|
141 | + $this->args['after']. |
|
142 | 142 | $this->args['errors'] |
143 | 143 | ); |
144 | 144 | |
@@ -172,15 +172,15 @@ discard block |
||
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 | 182 | $errors = array_reduce( $field_errors['errors'], function( $carry, $error ) { |
183 | - return $carry . sprintf( '<span>%s</span> ', $error ); |
|
183 | + return $carry.sprintf( '<span>%s</span> ', $error ); |
|
184 | 184 | }); |
185 | 185 | |
186 | 186 | $this->args['errors'] = sprintf( '<span class="glsr-field-errors">%s</span>', $errors ); |
@@ -193,17 +193,17 @@ discard block |
||
193 | 193 | */ |
194 | 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 | 202 | foreach( $attributes as $key => $value ) { |
203 | - if( is_string( $key ))continue; |
|
204 | - unset( $attributes[ $key ] ); |
|
205 | - if( !isset( $attributes[ $value ] )) { |
|
206 | - $attributes[ $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 | |
@@ -221,7 +221,7 @@ discard block |
||
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 | /** |
@@ -329,21 +329,21 @@ 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 )) { |
|
337 | + if( is_array( $depends ) ) { |
|
338 | 338 | reset( $depends ); |
339 | 339 | $name = key( $depends ); |
340 | - $value = $depends[ $name ]; |
|
340 | + $value = $depends[$name]; |
|
341 | 341 | } |
342 | 342 | |
343 | - $name = $this->parseName([ |
|
343 | + $name = $this->parseName( [ |
|
344 | 344 | 'name' => $name, |
345 | 345 | 'prefix' => $this->args['prefix'], |
346 | - ]); |
|
346 | + ] ); |
|
347 | 347 | |
348 | 348 | return $this->args['attributes']['data-depends'] = [ |
349 | 349 | 'name' => $name, |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use Exception; |
6 | 6 | use ReflectionException; |
7 | 7 | |
8 | -class Field |
|
9 | -{ |
|
8 | +class Field { |
|
10 | 9 | /** |
11 | 10 | * @var array |
12 | 11 | */ |
@@ -119,7 +118,9 @@ discard block |
||
119 | 118 | */ |
120 | 119 | public function render( $print = true ) |
121 | 120 | { |
122 | - if( $this->args['render'] === false )return; |
|
121 | + if( $this->args['render'] === false ) { |
|
122 | + return; |
|
123 | + } |
|
123 | 124 | |
124 | 125 | $field = $this->getField(); |
125 | 126 | |
@@ -203,7 +204,9 @@ discard block |
||
203 | 204 | $attributes = (array) $args['attributes']; |
204 | 205 | |
205 | 206 | foreach( $attributes as $key => $value ) { |
206 | - if( is_string( $key ))continue; |
|
207 | + if( is_string( $key )) { |
|
208 | + continue; |
|
209 | + } |
|
207 | 210 | unset( $attributes[ $key ] ); |
208 | 211 | if( !isset( $attributes[ $value ] )) { |
209 | 212 | $attributes[ $value ] = ''; |
@@ -220,7 +223,9 @@ discard block |
||
220 | 223 | */ |
221 | 224 | protected function parseId( array $args ) |
222 | 225 | { |
223 | - if( isset( $args['id'] ) && !$args['id'] )return; |
|
226 | + if( isset( $args['id'] ) && !$args['id'] ) { |
|
227 | + return; |
|
228 | + } |
|
224 | 229 | |
225 | 230 | !$args['suffix'] ?: $args['suffix'] = "-{$args['suffix']}"; |
226 | 231 | |
@@ -332,7 +337,9 @@ discard block |
||
332 | 337 | */ |
333 | 338 | protected function setDataDepends() |
334 | 339 | { |
335 | - if( !( $depends = $this->args['depends'] ))return; |
|
340 | + if( !( $depends = $this->args['depends'] )) { |
|
341 | + return; |
|
342 | + } |
|
336 | 343 | |
337 | 344 | $name = $depends; |
338 | 345 | $value = true; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct() |
14 | 14 | { |
15 | - $this->assets = sprintf( '%s/assets/', dirname( __DIR__ )); |
|
15 | + $this->assets = sprintf( '%s/assets/', dirname( __DIR__ ) ); |
|
16 | 16 | Facade::clearResolvedInstances(); |
17 | 17 | Facade::setFacadeApplication( $this ); |
18 | 18 | $this->registerAliases(); |
@@ -24,21 +24,21 @@ discard block |
||
24 | 24 | $controller = $this->make( 'Controller' ); |
25 | 25 | |
26 | 26 | // Action hooks |
27 | - add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
28 | - add_action( 'login_head', [$controller, 'loadAdminFavicon'] ); |
|
29 | - add_action( 'admin_head', [$controller, 'loadAdminFavicon'] ); |
|
30 | - add_action( 'login_head', [$controller, 'login'] ); |
|
31 | - add_action( 'admin_enqueue_scripts', [$controller, 'registerAdminAssets'] ); |
|
32 | - add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
33 | - add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
27 | + add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
28 | + add_action( 'login_head', [$controller, 'loadAdminFavicon'] ); |
|
29 | + add_action( 'admin_head', [$controller, 'loadAdminFavicon'] ); |
|
30 | + add_action( 'login_head', [$controller, 'login'] ); |
|
31 | + add_action( 'admin_enqueue_scripts', [$controller, 'registerAdminAssets'] ); |
|
32 | + add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
33 | + add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
34 | 34 | add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] ); |
35 | - add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
35 | + add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
36 | 36 | |
37 | 37 | // Filter hooks |
38 | - add_filter( 'body_class', [$controller, 'filterBodyClasses'] ); |
|
39 | - add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
40 | - add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
41 | - add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
38 | + add_filter( 'body_class', [$controller, 'filterBodyClasses'] ); |
|
39 | + add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
40 | + add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
41 | + add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
42 | 42 | |
43 | 43 | foreach( $this->getTemplateTypes() as $type ) { |
44 | 44 | add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] ); |
@@ -6,8 +6,7 @@ |
||
6 | 6 | use GeminiLabs\Castor\Container; |
7 | 7 | use GeminiLabs\Castor\Facade; |
8 | 8 | |
9 | -final class Application extends Container |
|
10 | -{ |
|
9 | +final class Application extends Container { |
|
11 | 10 | public $assets; |
12 | 11 | public $cssDir; |
13 | 12 | public $imgDir; |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | { |
33 | 33 | $args = wp_parse_args( $args, [ |
34 | 34 | 'embed_type' => '', |
35 | - ]); |
|
35 | + ] ); |
|
36 | 36 | $request = $this->oembed->fetch( $this->oembed->get_provider( $url ), $url, [ |
37 | 37 | 'width' => 1280, |
38 | 38 | 'height' => 1280, |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | if( $request === false )return; |
41 | 41 | if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type )return; |
42 | 42 | return $this->modifyRequest( $request, $args ); |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | ? $this->$providerName |
57 | 57 | : []; |
58 | 58 | |
59 | - $method = $this->utility->buildMethodName( $providerName . '_request', 'modify' ); |
|
59 | + $method = $this->utility->buildMethodName( $providerName.'_request', 'modify' ); |
|
60 | 60 | |
61 | - if( method_exists( $this, $method )) { |
|
61 | + if( method_exists( $this, $method ) ) { |
|
62 | 62 | return call_user_func( [$this, $method], $request, array_intersect_key( |
63 | 63 | $args, |
64 | 64 | array_flip( $provider ) |
65 | - )); |
|
65 | + ) ); |
|
66 | 66 | } |
67 | 67 | return $request; |
68 | 68 | } |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | protected function modifyYoutubeRequest( $request, array $args ) |
71 | 71 | { |
72 | 72 | $html = $this->domLoad( $request->html ); |
73 | - $node = $html->getElementsByTagName( 'iframe' )->item(0); |
|
73 | + $node = $html->getElementsByTagName( 'iframe' )->item( 0 ); |
|
74 | 74 | $url = $node->getAttribute( 'src' ); |
75 | 75 | |
76 | 76 | if( isset( $args['fs'] ) && $args['fs'] == 0 ) { |
77 | 77 | $node->removeAttribute( 'allowfullscreen' ); |
78 | 78 | } |
79 | 79 | |
80 | - $args['origin'] = urlencode( get_bloginfo( 'url' )); |
|
80 | + $args['origin'] = urlencode( get_bloginfo( 'url' ) ); |
|
81 | 81 | |
82 | 82 | $node->setAttribute( 'class', 'video-embed' ); |
83 | 83 | $node->setAttribute( 'src', |
84 | - add_query_arg( $args, remove_query_arg( 'feature', $url )) |
|
84 | + add_query_arg( $args, remove_query_arg( 'feature', $url ) ) |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | $request->html = $html->saveHTML( $node ); |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use GeminiLabs\Castor\Helpers\Utility; |
6 | 6 | use DomDocument; |
7 | 7 | |
8 | -class Oembed |
|
9 | -{ |
|
8 | +class Oembed { |
|
10 | 9 | public $oembed; |
11 | 10 | public $utility; |
12 | 11 | |
@@ -37,8 +36,12 @@ discard block |
||
37 | 36 | 'width' => 1280, |
38 | 37 | 'height' => 1280, |
39 | 38 | ]); |
40 | - if( $request === false )return; |
|
41 | - if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type )return; |
|
39 | + if( $request === false ) { |
|
40 | + return; |
|
41 | + } |
|
42 | + if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type ) { |
|
43 | + return; |
|
44 | + } |
|
42 | 45 | return $this->modifyRequest( $request, $args ); |
43 | 46 | } |
44 | 47 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | foreach( $rules as $rule ) { |
79 | 79 | $this->validateAttribute( $rule, $attribute ); |
80 | 80 | |
81 | - if( $this->shouldStopValidating( $attribute ))break; |
|
81 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | { |
98 | 98 | $message = $this->getMessage( $attribute, $rule, $parameters ); |
99 | 99 | |
100 | - $this->errors[ $attribute ]['errors'][] = $message; |
|
100 | + $this->errors[$attribute]['errors'][] = $message; |
|
101 | 101 | |
102 | - if( !isset( $this->errors[ $attribute ]['value'] )) { |
|
103 | - $this->errors[ $attribute ]['value'] = $this->getValue( $attribute ); |
|
102 | + if( !isset( $this->errors[$attribute]['value'] ) ) { |
|
103 | + $this->errors[$attribute]['value'] = $this->getValue( $attribute ); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $this->addError( $attribute, $rule, $parameters ); |
118 | 118 | |
119 | - $this->failedRules[ $attribute ][ $rule ] = $parameters; |
|
119 | + $this->failedRules[$attribute][$rule] = $parameters; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | protected function getMessage( $attribute, $rule, array $parameters ) |
144 | 144 | { |
145 | - if( in_array( $rule, $this->sizeRules )) { |
|
145 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
146 | 146 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
147 | 147 | } |
148 | 148 | |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getRule( $attribute, $rules ) |
163 | 163 | { |
164 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
164 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
165 | 165 | |
166 | 166 | $rules = (array) $rules; |
167 | 167 | |
168 | - foreach( $this->rules[ $attribute ] as $rule ) { |
|
168 | + foreach( $this->rules[$attribute] as $rule ) { |
|
169 | 169 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
170 | 170 | |
171 | - if( in_array( $rule, $rules )) { |
|
172 | - return [ $rule, $parameters ]; |
|
171 | + if( in_array( $rule, $rules ) ) { |
|
172 | + return [$rule, $parameters]; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if( is_numeric( $value ) && $hasNumeric ) { |
190 | 190 | return $value; |
191 | 191 | } |
192 | - elseif( is_array( $value )) { |
|
192 | + elseif( is_array( $value ) ) { |
|
193 | 193 | return count( $value ); |
194 | 194 | } |
195 | 195 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | */ |
224 | 224 | protected function getValue( $attribute ) |
225 | 225 | { |
226 | - if( isset( $this->data[ $attribute ] )) { |
|
227 | - return $this->data[ $attribute ]; |
|
226 | + if( isset( $this->data[$attribute] ) ) { |
|
227 | + return $this->data[$attribute]; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | protected function hasRule( $attribute, $rules ) |
240 | 240 | { |
241 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
241 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | protected function normalizeData( $data ) |
252 | 252 | { |
253 | 253 | // If an object was provided, get its public properties |
254 | - if( is_object( $data )) { |
|
254 | + if( is_object( $data ) ) { |
|
255 | 255 | $this->data = get_object_vars( $data ); |
256 | 256 | } |
257 | 257 | else { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | protected function parseParameters( $rule, $parameter ) |
273 | 273 | { |
274 | 274 | if( strtolower( $rule ) == 'regex' ) { |
275 | - return [ $parameter ]; |
|
275 | + return [$parameter]; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return str_getcsv( $parameter ); |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | $parameters = $this->parseParameters( $rule, $parameter ); |
298 | 298 | } |
299 | 299 | |
300 | - $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ))); |
|
300 | + $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) ); |
|
301 | 301 | $rule = str_replace( ' ', '', $rule ); |
302 | 302 | |
303 | - return [ $rule, $parameters ]; |
|
303 | + return [$rule, $parameters]; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | protected function replaceBetween( $message, array $parameters ) |
314 | 314 | { |
315 | - return str_replace([':min', ':max'], $parameters, $message ); |
|
315 | + return str_replace( [':min', ':max'], $parameters, $message ); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | protected function setRules( array $rules ) |
364 | 364 | { |
365 | 365 | foreach( $rules as $key => $rule ) { |
366 | - $rules[ $key ] = is_string( $rule ) ? explode( '|', $rule ) : $rule; |
|
366 | + $rules[$key] = is_string( $rule ) ? explode( '|', $rule ) : $rule; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | $this->rules = $rules; |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | protected function shouldStopValidating( $attribute ) |
382 | 382 | { |
383 | 383 | return $this->hasRule( $attribute, $this->implicitRules ) |
384 | - && isset( $this->failedRules[ $attribute ] ) |
|
385 | - && array_intersect( array_keys( $this->failedRules[ $attribute ] ), $this->implicitRules ); |
|
384 | + && isset( $this->failedRules[$attribute] ) |
|
385 | + && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | */ |
395 | 395 | protected function snakeCase( $string ) |
396 | 396 | { |
397 | - if( !ctype_lower( $string )) { |
|
397 | + if( !ctype_lower( $string ) ) { |
|
398 | 398 | $string = preg_replace( '/\s+/u', '', $string ); |
399 | 399 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
400 | 400 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | protected function translator( $key, $rule, $attribute, array $parameters ) |
416 | 416 | { |
417 | - $strings = [];//glsr_resolve( 'Strings' )->validation(); |
|
417 | + $strings = []; //glsr_resolve( 'Strings' )->validation(); |
|
418 | 418 | |
419 | 419 | $message = isset( $strings[$key] ) |
420 | 420 | ? $strings[$key] |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | |
425 | 425 | $message = str_replace( ':attribute', $attribute, $message ); |
426 | 426 | |
427 | - if( method_exists( $this, $replacer = "replace{$rule}" )) { |
|
427 | + if( method_exists( $this, $replacer = "replace{$rule}" ) ) { |
|
428 | 428 | $message = $this->$replacer( $message, $parameters ); |
429 | 429 | } |
430 | 430 | |
@@ -467,11 +467,11 @@ discard block |
||
467 | 467 | |
468 | 468 | $method = "validate{$rule}"; |
469 | 469 | |
470 | - if( !method_exists( $this, $method )) { |
|
470 | + if( !method_exists( $this, $method ) ) { |
|
471 | 471 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
472 | 472 | } |
473 | 473 | |
474 | - if( !$this->$method( $this->getValue( $attribute ), $attribute, $parameters )) { |
|
474 | + if( !$this->$method( $this->getValue( $attribute ), $attribute, $parameters ) ) { |
|
475 | 475 | $this->addFailure( $attribute, $rule, $parameters ); |
476 | 476 | } |
477 | 477 | } |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | */ |
557 | 557 | protected function validateRequired( $value ) |
558 | 558 | { |
559 | - if( is_string( $value )) { |
|
559 | + if( is_string( $value ) ) { |
|
560 | 560 | $value = trim( $value ); |
561 | 561 | } |
562 | 562 | return is_null( $value ) || empty( $value ) |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use BadMethodCallException; |
6 | 6 | use InvalidArgumentException; |
7 | 7 | |
8 | -class Validator |
|
9 | -{ |
|
8 | +class Validator { |
|
10 | 9 | /** |
11 | 10 | * @var array |
12 | 11 | */ |
@@ -78,7 +77,9 @@ discard block |
||
78 | 77 | foreach( $rules as $rule ) { |
79 | 78 | $this->validateAttribute( $rule, $attribute ); |
80 | 79 | |
81 | - if( $this->shouldStopValidating( $attribute ))break; |
|
80 | + if( $this->shouldStopValidating( $attribute )) { |
|
81 | + break; |
|
82 | + } |
|
82 | 83 | } |
83 | 84 | } |
84 | 85 | |
@@ -161,7 +162,9 @@ discard block |
||
161 | 162 | */ |
162 | 163 | protected function getRule( $attribute, $rules ) |
163 | 164 | { |
164 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
165 | + if( !array_key_exists( $attribute, $this->rules )) { |
|
166 | + return; |
|
167 | + } |
|
165 | 168 | |
166 | 169 | $rules = (array) $rules; |
167 | 170 | |
@@ -420,7 +423,9 @@ discard block |
||
420 | 423 | ? $strings[$key] |
421 | 424 | : false; |
422 | 425 | |
423 | - if( !$message )return; |
|
426 | + if( !$message ) { |
|
427 | + return; |
|
428 | + } |
|
424 | 429 | |
425 | 430 | $message = str_replace( ':attribute', $attribute, $message ); |
426 | 431 | |
@@ -463,7 +468,9 @@ discard block |
||
463 | 468 | { |
464 | 469 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
465 | 470 | |
466 | - if( $rule == '' )return; |
|
471 | + if( $rule == '' ) { |
|
472 | + return; |
|
473 | + } |
|
467 | 474 | |
468 | 475 | $method = "validate{$rule}"; |
469 | 476 |
@@ -6,8 +6,7 @@ |
||
6 | 6 | use GeminiLabs\Castor\Facades\Log as LogFacade; |
7 | 7 | use GeminiLabs\Castor\Facades\Utility as UtilityFacade; |
8 | 8 | |
9 | -class Template |
|
10 | -{ |
|
9 | +class Template { |
|
11 | 10 | /** |
12 | 11 | * @var string |
13 | 12 | */ |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | { |
24 | 24 | $template = UtilityFacade::startWith( 'templates/', $slug ); |
25 | 25 | $templates = ["$template.php"]; |
26 | - if( !empty( $name )) { |
|
26 | + if( !empty( $name ) ) { |
|
27 | 27 | $fileName = basename( $template ); |
28 | 28 | $filePath = UtilityFacade::trimRight( $template, $fileName ); |
29 | - array_unshift( $templates, sprintf( '%s/%s.php', $filePath.$name, $fileName )); |
|
29 | + array_unshift( $templates, sprintf( '%s/%s.php', $filePath.$name, $fileName ) ); |
|
30 | 30 | } |
31 | - $templates = array_unique( apply_filters( "castor/templates/$slug", $templates, $name )); |
|
31 | + $templates = array_unique( apply_filters( "castor/templates/$slug", $templates, $name ) ); |
|
32 | 32 | $template = locate_template( $templates ); |
33 | - if( empty( $template )) { |
|
34 | - if( file_exists( "$slug.php" )) { |
|
33 | + if( empty( $template ) ) { |
|
34 | + if( file_exists( "$slug.php" ) ) { |
|
35 | 35 | return "$slug.php"; |
36 | 36 | } |
37 | 37 | LogFacade::debug( "$slug not found." ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function load( $slug, $name = '' ) |
49 | 49 | { |
50 | - if( !empty(( $template = $this->get( $slug, $name )))) { |
|
50 | + if( !empty( ( $template = $this->get( $slug, $name ) ) ) ) { |
|
51 | 51 | DevelopmentFacade::storeTemplatePath( $template ); |
52 | 52 | load_template( $template, false ); |
53 | 53 | } |
@@ -70,6 +70,6 @@ discard block |
||
70 | 70 | { |
71 | 71 | $template = str_replace( get_stylesheet_directory().'/templates/', '', $template ); |
72 | 72 | $this->template = UtilityFacade::trimRight( $template, '.php' ); |
73 | - return $this->get( apply_filters( 'castor/templates/layout', 'layouts/default' )); |
|
73 | + return $this->get( apply_filters( 'castor/templates/layout', 'layouts/default' ) ); |
|
74 | 74 | } |
75 | 75 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function interpolate( $message, array $context = [] ) |
153 | 153 | { |
154 | - if( is_array( $message )) { |
|
154 | + if( is_array( $message ) ) { |
|
155 | 155 | return htmlspecialchars( print_r( $message, true ), ENT_QUOTES, 'UTF-8' ); |
156 | 156 | } |
157 | 157 | $replace = []; |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | if( is_object( $val ) && get_class( $val ) === 'DateTime' ) { |
160 | 160 | $val = $val->format( 'Y-m-d H:i:s' ); |
161 | 161 | } |
162 | - else if( is_object( $val ) || is_array( $val )) { |
|
162 | + else if( is_object( $val ) || is_array( $val ) ) { |
|
163 | 163 | $val = json_encode( $val ); |
164 | 164 | } |
165 | - else if( is_resource( $val )) { |
|
165 | + else if( is_resource( $val ) ) { |
|
166 | 166 | $val = (string) $val; |
167 | 167 | } |
168 | 168 | $replace['{'.$key.'}'] = $val; |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function log( $level, $message, array $context = [] ) |
180 | 180 | { |
181 | - if( !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
|
181 | + if( !in_array( $level, ( new ReflectionClass( __NAMESPACE__.'\Log' ) )->getConstants(), true ) |
|
182 | 182 | || !DevelopmentFacade::isDev() |
183 | 183 | )return; |
184 | - $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
|
184 | + $date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ); |
|
185 | 185 | $level = strtoupper( $level ); |
186 | 186 | $message = $this->interpolate( $message, $context ); |
187 | - $entry = "[$date] $level: $message" . PHP_EOL; |
|
188 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
187 | + $entry = "[$date] $level: $message".PHP_EOL; |
|
188 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
189 | 189 | } |
190 | 190 | } |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use GeminiLabs\Castor\Facades\Development as DevelopmentFacade; |
6 | 6 | use ReflectionClass; |
7 | 7 | |
8 | -class Log |
|
9 | -{ |
|
8 | +class Log { |
|
10 | 9 | const EMERGENCY = 'emergency'; |
11 | 10 | const ALERT = 'alert'; |
12 | 11 | const CRITICAL = 'critical'; |
@@ -180,7 +179,9 @@ discard block |
||
180 | 179 | { |
181 | 180 | if( !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
182 | 181 | || !DevelopmentFacade::isDev() |
183 | - )return; |
|
182 | + ) { |
|
183 | + return; |
|
184 | + } |
|
184 | 185 | $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
185 | 186 | $level = strtoupper( $level ); |
186 | 187 | $message = $this->interpolate( $message, $context ); |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | global $wp_version; |
4 | 4 | |
5 | -if( !is_admin() && version_compare( '7.0', phpversion(), '>' )) { |
|
5 | +if( !is_admin() && version_compare( '7.0', phpversion(), '>' ) ) { |
|
6 | 6 | wp_die( |
7 | 7 | __( 'You must be using PHP 7.0.0 or greater.', 'castor' ), |
8 | 8 | __( 'Unsupported PHP version', 'castor' ) |
9 | 9 | ); |
10 | 10 | } |
11 | -if( !is_admin() && version_compare( '4.7', $wp_version, '>' )) { |
|
11 | +if( !is_admin() && version_compare( '4.7', $wp_version, '>' ) ) { |
|
12 | 12 | wp_die( |
13 | 13 | __( 'You must be using WordPress 4.7.0 or greater.', 'castor' ), |
14 | 14 | __( 'Unsupported WordPress version', 'castor' ) |
15 | 15 | ); |
16 | 16 | } |
17 | -if( is_customize_preview() && filter_input( INPUT_GET, 'theme' )) { |
|
17 | +if( is_customize_preview() && filter_input( INPUT_GET, 'theme' ) ) { |
|
18 | 18 | wp_die( |
19 | 19 | __( 'Theme must be activated prior to using the customizer.', 'castor' ) |
20 | 20 | ); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | require_once( ABSPATH.'/'.WPINC.'/class-oembed.php' ); |
24 | 24 | |
25 | -if( !function_exists( 'castor_app' )) { |
|
25 | +if( !function_exists( 'castor_app' ) ) { |
|
26 | 26 | function castor_app() { |
27 | 27 | return \GeminiLabs\Castor\Application::getInstance(); |
28 | 28 | } |
@@ -23,7 +23,8 @@ |
||
23 | 23 | require_once( ABSPATH.'/'.WPINC.'/class-oembed.php' ); |
24 | 24 | |
25 | 25 | if( !function_exists( 'castor_app' )) { |
26 | - function castor_app() { |
|
26 | + function castor_app() |
|
27 | + { |
|
27 | 28 | return \GeminiLabs\Castor\Application::getInstance(); |
28 | 29 | } |
29 | 30 | } |