@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | /** |
| 89 | 89 | * @param array<string, mixed> $settings |
| 90 | 90 | */ |
| 91 | - public function __construct( array $settings = array() ) { |
|
| 92 | - $settings = $this->set_defaults( $settings ); |
|
| 93 | - $this->set_props( $settings ); |
|
| 91 | + public function __construct(array $settings = array()) { |
|
| 92 | + $settings = $this->set_defaults($settings); |
|
| 93 | + $this->set_props($settings); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * @param array<string, mixed> $settings |
| 100 | 100 | * @return array<string, mixed> |
| 101 | 101 | */ |
| 102 | - private function set_defaults( array $settings ): array { |
|
| 103 | - return array_replace_recursive( $this->settings_defaults(), $settings ); |
|
| 102 | + private function set_defaults(array $settings): array { |
|
| 103 | + return array_replace_recursive($this->settings_defaults(), $settings); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -109,17 +109,17 @@ discard block |
||
| 109 | 109 | * @param array<string, mixed> $settings |
| 110 | 110 | * @return void |
| 111 | 111 | */ |
| 112 | - private function set_props( array $settings ): void { |
|
| 112 | + private function set_props(array $settings): void { |
|
| 113 | 113 | $this->paths['url'] = $settings['url']; |
| 114 | 114 | $this->paths['path'] = $settings['path']; |
| 115 | - $this->namespaces = $this->filter_key_value_pair( $settings['namespaces'] ); |
|
| 115 | + $this->namespaces = $this->filter_key_value_pair($settings['namespaces']); |
|
| 116 | 116 | $this->plugin = $settings['plugin']; |
| 117 | 117 | $this->additional = $settings['additional']; |
| 118 | - $this->db_tables = $this->filter_key_value_pair( $settings['db_tables'] ); |
|
| 119 | - $this->post_types = $this->filter_key_value_pair( $settings['post_types'] ); |
|
| 120 | - $this->taxonomies = $this->filter_key_value_pair( $settings['taxonomies'] ); |
|
| 118 | + $this->db_tables = $this->filter_key_value_pair($settings['db_tables']); |
|
| 119 | + $this->post_types = $this->filter_key_value_pair($settings['post_types']); |
|
| 120 | + $this->taxonomies = $this->filter_key_value_pair($settings['taxonomies']); |
|
| 121 | 121 | |
| 122 | - $this->set_meta( $settings['meta'] ); |
|
| 122 | + $this->set_meta($settings['meta']); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * @param string|null $default The default value to return if not set. |
| 130 | 130 | * @return array<string, mixed>|string|null |
| 131 | 131 | */ |
| 132 | - public function path( ?string $path = null, ?string $default = null ) { |
|
| 132 | + public function path(?string $path = null, ?string $default = null) { |
|
| 133 | 133 | |
| 134 | - if ( is_null( $path ) ) { |
|
| 134 | + if (is_null($path)) { |
|
| 135 | 135 | return $this->paths['path']; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - return \array_key_exists( $path, $this->paths['path'] ) |
|
| 139 | - ? trailingslashit( $this->paths['path'][ $path ] ) |
|
| 138 | + return \array_key_exists($path, $this->paths['path']) |
|
| 139 | + ? trailingslashit($this->paths['path'][$path]) |
|
| 140 | 140 | : $default; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | * @param string|null $default The default value to return if not set. |
| 148 | 148 | * @return array<string, mixed>|string|null |
| 149 | 149 | */ |
| 150 | - public function url( ?string $url = null, ?string $default = null ) { |
|
| 150 | + public function url(?string $url = null, ?string $default = null) { |
|
| 151 | 151 | |
| 152 | - if ( is_null( $url ) ) { |
|
| 152 | + if (is_null($url)) { |
|
| 153 | 153 | return $this->paths['url']; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return \array_key_exists( $url, $this->paths['url'] ) |
|
| 157 | - ? trailingslashit( $this->paths['url'][ $url ] ) |
|
| 156 | + return \array_key_exists($url, $this->paths['url']) |
|
| 157 | + ? trailingslashit($this->paths['url'][$url]) |
|
| 158 | 158 | : $default; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * @param string|null $default The default value to return if not set. |
| 184 | 184 | * @return string|null |
| 185 | 185 | */ |
| 186 | - public function namespace( string $key, ?string $default = null ): ?string { |
|
| 187 | - return array_key_exists( $key, $this->namespaces ) |
|
| 188 | - ? $this->namespaces[ $key ] : $default; |
|
| 186 | + public function namespace(string $key, ?string $default = null) : ?string { |
|
| 187 | + return array_key_exists($key, $this->namespaces) |
|
| 188 | + ? $this->namespaces[$key] : $default; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | * @param string|null $default The default value to return if not set. |
| 196 | 196 | * @return mixed |
| 197 | 197 | */ |
| 198 | - public function additional( string $key, ?string $default = null ) { |
|
| 199 | - return array_key_exists( $key, $this->additional ) |
|
| 200 | - ? $this->additional[ $key ] : $default; |
|
| 198 | + public function additional(string $key, ?string $default = null) { |
|
| 199 | + return array_key_exists($key, $this->additional) |
|
| 200 | + ? $this->additional[$key] : $default; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -216,12 +216,12 @@ discard block |
||
| 216 | 216 | * @return string |
| 217 | 217 | * @throws OutOfBoundsException |
| 218 | 218 | */ |
| 219 | - public function post_types( string $key ) { |
|
| 220 | - if ( ! array_key_exists( $key, $this->post_types ) ) { |
|
| 221 | - throw new OutOfBoundsException( "App Config :: \"{$key}\" is not a defined post type" ); |
|
| 219 | + public function post_types(string $key) { |
|
| 220 | + if ( ! array_key_exists($key, $this->post_types)) { |
|
| 221 | + throw new OutOfBoundsException("App Config :: \"{$key}\" is not a defined post type"); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - return $this->post_types[ $key ]; |
|
| 224 | + return $this->post_types[$key]; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -232,17 +232,17 @@ discard block |
||
| 232 | 232 | * @return string |
| 233 | 233 | * @throws OutOfBoundsException |
| 234 | 234 | */ |
| 235 | - public function meta( string $key, string $type = self::POST_META ): string { |
|
| 235 | + public function meta(string $key, string $type = self::POST_META): string { |
|
| 236 | 236 | // Check meta type. |
| 237 | - if ( ! array_key_exists( $type, $this->meta ) ) { |
|
| 238 | - throw new OutOfBoundsException( "App Config :: \"{$type}\" is not a valid meta type and cant be fetched" ); |
|
| 237 | + if ( ! array_key_exists($type, $this->meta)) { |
|
| 238 | + throw new OutOfBoundsException("App Config :: \"{$type}\" is not a valid meta type and cant be fetched"); |
|
| 239 | 239 | } |
| 240 | 240 | // Check key. |
| 241 | - if ( ! array_key_exists( $key, $this->meta[ $type ] ) ) { |
|
| 242 | - throw new OutOfBoundsException( "App Config :: \"{$key}\" is not a defined {$type} meta key" ); |
|
| 241 | + if ( ! array_key_exists($key, $this->meta[$type])) { |
|
| 242 | + throw new OutOfBoundsException("App Config :: \"{$key}\" is not a defined {$type} meta key"); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - return $this->meta[ $type ][ $key ]; |
|
| 245 | + return $this->meta[$type][$key]; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | * @param string $key |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | - public function post_meta( string $key ): string { |
|
| 256 | - return $this->meta( $key, self::POST_META ); |
|
| 255 | + public function post_meta(string $key): string { |
|
| 256 | + return $this->meta($key, self::POST_META); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | * @param string $key |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - public function user_meta( string $key ): string { |
|
| 267 | - return $this->meta( $key, self::USER_META ); |
|
| 266 | + public function user_meta(string $key): string { |
|
| 267 | + return $this->meta($key, self::USER_META); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | * @param string $key |
| 275 | 275 | * @return string |
| 276 | 276 | */ |
| 277 | - public function term_meta( string $key ): string { |
|
| 278 | - return $this->meta( $key, self::TERM_META ); |
|
| 277 | + public function term_meta(string $key): string { |
|
| 278 | + return $this->meta($key, self::TERM_META); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -284,15 +284,15 @@ discard block |
||
| 284 | 284 | * @param array<string, array<string,string>> $meta |
| 285 | 285 | * @return void |
| 286 | 286 | */ |
| 287 | - public function set_meta( array $meta ): void { |
|
| 288 | - $valid_meta_types = array( self::POST_META, self::USER_META, self::TERM_META ); |
|
| 289 | - foreach ( $meta as $meta_type => $pairs ) { |
|
| 290 | - if ( ! in_array( $meta_type, $valid_meta_types, true ) ) { |
|
| 291 | - throw new OutOfBoundsException( "App Config :: \"{$meta_type}\" is not a valid meta type and cant be defined" ); |
|
| 287 | + public function set_meta(array $meta): void { |
|
| 288 | + $valid_meta_types = array(self::POST_META, self::USER_META, self::TERM_META); |
|
| 289 | + foreach ($meta as $meta_type => $pairs) { |
|
| 290 | + if ( ! in_array($meta_type, $valid_meta_types, true)) { |
|
| 291 | + throw new OutOfBoundsException("App Config :: \"{$meta_type}\" is not a valid meta type and cant be defined"); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // Set all pairs which have both valid key and values. |
| 295 | - $this->meta[ $meta_type ] = $this->filter_key_value_pair( $pairs ); |
|
| 295 | + $this->meta[$meta_type] = $this->filter_key_value_pair($pairs); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
@@ -303,12 +303,12 @@ discard block |
||
| 303 | 303 | * @return string |
| 304 | 304 | * @throws OutOfBoundsException |
| 305 | 305 | */ |
| 306 | - public function taxonomies( string $key ): string { |
|
| 307 | - if ( ! array_key_exists( $key, $this->taxonomies ) ) { |
|
| 308 | - throw new OutOfBoundsException( "App Config :: \"{$key}\" is not a defined taxonomy" ); |
|
| 306 | + public function taxonomies(string $key): string { |
|
| 307 | + if ( ! array_key_exists($key, $this->taxonomies)) { |
|
| 308 | + throw new OutOfBoundsException("App Config :: \"{$key}\" is not a defined taxonomy"); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - return $this->taxonomies[ $key ]; |
|
| 311 | + return $this->taxonomies[$key]; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
@@ -319,11 +319,11 @@ discard block |
||
| 319 | 319 | * @return string |
| 320 | 320 | * @throws OutOfBoundsException |
| 321 | 321 | */ |
| 322 | - public function db_tables( string $name ): string { |
|
| 323 | - if ( ! array_key_exists( $name, $this->db_tables ) ) { |
|
| 324 | - throw new OutOfBoundsException( "App Config :: \"{$name}\" is not a defined DB table" ); |
|
| 322 | + public function db_tables(string $name): string { |
|
| 323 | + if ( ! array_key_exists($name, $this->db_tables)) { |
|
| 324 | + throw new OutOfBoundsException("App Config :: \"{$name}\" is not a defined DB table"); |
|
| 325 | 325 | } |
| 326 | - return $this->db_tables[ $name ]; |
|
| 326 | + return $this->db_tables[$name]; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | * @param string $name |
| 333 | 333 | * @return mixed |
| 334 | 334 | */ |
| 335 | - public function __get( $name ) { |
|
| 336 | - return $this->additional( $name ); |
|
| 335 | + public function __get($name) { |
|
| 336 | + return $this->additional($name); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @return array<string, mixed> |
| 343 | 343 | */ |
| 344 | 344 | private function settings_defaults(): array { |
| 345 | - $base_path = \dirname( __DIR__, 2 ); |
|
| 346 | - $plugin_dir = \basename( $base_path ); |
|
| 345 | + $base_path = \dirname(__DIR__, 2); |
|
| 346 | + $plugin_dir = \basename($base_path); |
|
| 347 | 347 | $wp_uploads = \wp_upload_dir(); |
| 348 | 348 | |
| 349 | 349 | return array( |
@@ -358,9 +358,9 @@ discard block |
||
| 358 | 358 | 'upload_current' => $wp_uploads['path'], |
| 359 | 359 | ), |
| 360 | 360 | 'url' => array( |
| 361 | - 'plugin' => plugins_url( $plugin_dir ), |
|
| 362 | - 'view' => plugins_url( $plugin_dir ) . '/views', |
|
| 363 | - 'assets' => plugins_url( $plugin_dir ) . '/assets', |
|
| 361 | + 'plugin' => plugins_url($plugin_dir), |
|
| 362 | + 'view' => plugins_url($plugin_dir) . '/views', |
|
| 363 | + 'assets' => plugins_url($plugin_dir) . '/assets', |
|
| 364 | 364 | 'upload_root' => $wp_uploads['baseurl'], |
| 365 | 365 | 'upload_current' => $wp_uploads['url'], |
| 366 | 366 | ), |
@@ -386,14 +386,14 @@ discard block |
||
| 386 | 386 | * @param array<int|string, mixed> $pairs |
| 387 | 387 | * @return array<string, string> |
| 388 | 388 | */ |
| 389 | - private function filter_key_value_pair( array $pairs ): array { |
|
| 389 | + private function filter_key_value_pair(array $pairs): array { |
|
| 390 | 390 | /** @var array<string, string> (as per filter function)*/ |
| 391 | 391 | return array_filter( |
| 392 | 392 | $pairs, |
| 393 | - function ( $value, $key ): bool { |
|
| 394 | - return is_string( $value ) |
|
| 395 | - && \mb_strlen( $value ) > 0 |
|
| 396 | - && is_string( $key ); |
|
| 393 | + function($value, $key): bool { |
|
| 394 | + return is_string($value) |
|
| 395 | + && \mb_strlen($value) > 0 |
|
| 396 | + && is_string($key); |
|
| 397 | 397 | }, |
| 398 | 398 | ARRAY_FILTER_USE_BOTH |
| 399 | 399 | ); |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param string $base_view_path |
| 53 | 53 | */ |
| 54 | - public function __construct( string $base_view_path ) { |
|
| 55 | - $this->base_view_path = $this->verify_view_path( $base_view_path ); |
|
| 54 | + public function __construct(string $base_view_path) { |
|
| 55 | + $this->base_view_path = $this->verify_view_path($base_view_path); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param Component_Compiler $compiler |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - public function set_component_compiler( Component_Compiler $compiler ): void { |
|
| 64 | + public function set_component_compiler(Component_Compiler $compiler): void { |
|
| 65 | 65 | $this->component_compiler = $compiler; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * @param bool $print |
| 74 | 74 | * @return string|void |
| 75 | 75 | */ |
| 76 | - public function render( string $view, iterable $data, bool $print = true ) { |
|
| 77 | - $view = $this->resolve_file_path( $view ); |
|
| 78 | - if ( $print ) { |
|
| 79 | - print( $this->render_buffer( $view, $data ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 76 | + public function render(string $view, iterable $data, bool $print = true) { |
|
| 77 | + $view = $this->resolve_file_path($view); |
|
| 78 | + if ($print) { |
|
| 79 | + print($this->render_buffer($view, $data)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 80 | 80 | } else { |
| 81 | - return $this->render_buffer( $view, $data ); |
|
| 81 | + return $this->render_buffer($view, $data); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -88,21 +88,21 @@ discard block |
||
| 88 | 88 | * @param Component $component |
| 89 | 89 | * @return string|void |
| 90 | 90 | */ |
| 91 | - public function component( Component $component, bool $print = true ) { |
|
| 91 | + public function component(Component $component, bool $print = true) { |
|
| 92 | 92 | |
| 93 | 93 | // Throw exception of no compiler passed. |
| 94 | - if ( ! is_a( $this->component_compiler, Component_Compiler::class ) ) { |
|
| 95 | - throw new Exception( 'No component compiler passed to PHP_Engine' ); |
|
| 94 | + if ( ! is_a($this->component_compiler, Component_Compiler::class)) { |
|
| 95 | + throw new Exception('No component compiler passed to PHP_Engine'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Compile the component. |
| 99 | - $compiled = $this->component_compiler->compile( $component ); |
|
| 100 | - $template = $this->maybe_resolve_dot_notation( $compiled->template() ); |
|
| 101 | - $view = sprintf( '%s%s.php', \DIRECTORY_SEPARATOR, ltrim( $template ) ); |
|
| 102 | - if ( $print ) { |
|
| 103 | - print( $this->render_buffer( $view, $compiled->data() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 99 | + $compiled = $this->component_compiler->compile($component); |
|
| 100 | + $template = $this->maybe_resolve_dot_notation($compiled->template()); |
|
| 101 | + $view = sprintf('%s%s.php', \DIRECTORY_SEPARATOR, ltrim($template)); |
|
| 102 | + if ($print) { |
|
| 103 | + print($this->render_buffer($view, $compiled->data())); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 104 | 104 | } else { |
| 105 | - return $this->render_buffer( $view, $compiled->data() ); |
|
| 105 | + return $this->render_buffer($view, $compiled->data()); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | * @param View_Model $view_model |
| 114 | 114 | * @return string|void |
| 115 | 115 | */ |
| 116 | - public function view_model( View_Model $view_model, bool $print = true ) { |
|
| 117 | - return $this->render( $view_model->template(), $view_model->data(), $print ); |
|
| 116 | + public function view_model(View_Model $view_model, bool $print = true) { |
|
| 117 | + return $this->render($view_model->template(), $view_model->data(), $print); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | * @param bool $print |
| 126 | 126 | * @return string|void |
| 127 | 127 | */ |
| 128 | - public function partial( string $view, iterable $data = array(), bool $print = true ) { |
|
| 129 | - if ( $print ) { |
|
| 130 | - $this->render( $view, $data, $print ); |
|
| 128 | + public function partial(string $view, iterable $data = array(), bool $print = true) { |
|
| 129 | + if ($print) { |
|
| 130 | + $this->render($view, $data, $print); |
|
| 131 | 131 | } else { |
| 132 | - return $this->render( $view, $data, $print ); |
|
| 132 | + return $this->render($view, $data, $print); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -141,27 +141,27 @@ discard block |
||
| 141 | 141 | * @return string |
| 142 | 142 | * @throws Exception |
| 143 | 143 | */ |
| 144 | - protected function render_buffer( string $view, iterable $__data ): string { |
|
| 144 | + protected function render_buffer(string $view, iterable $__data): string { |
|
| 145 | 145 | |
| 146 | - if ( ! file_exists( $view ) ) { |
|
| 147 | - throw new Exception( "{$view} doesn't exist" ); |
|
| 146 | + if ( ! file_exists($view)) { |
|
| 147 | + throw new Exception("{$view} doesn't exist"); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $output = ''; |
| 151 | 151 | ob_start(); |
| 152 | 152 | |
| 153 | 153 | // Set all the data values a parameters. |
| 154 | - foreach ( $__data as $__key => $__value ) { |
|
| 155 | - if ( is_string( $__key ) ) { |
|
| 156 | - ${\wp_strip_all_tags( $__key )} = $__value; |
|
| 154 | + foreach ($__data as $__key => $__value) { |
|
| 155 | + if (is_string($__key)) { |
|
| 156 | + ${\wp_strip_all_tags($__key)} = $__value; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Unset the key and value. |
| 160 | - unset( $__key, $__value ); |
|
| 160 | + unset($__key, $__value); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Unset the data. |
| 164 | - unset( $__data ); |
|
| 164 | + unset($__data); |
|
| 165 | 165 | |
| 166 | 166 | include $view; |
| 167 | 167 | $output = ob_get_contents(); |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | * @param string $filename |
| 176 | 176 | * @return string |
| 177 | 177 | */ |
| 178 | - protected function resolve_file_path( string $filename ): string { |
|
| 179 | - $filename = $this->maybe_resolve_dot_notation( $filename ); |
|
| 178 | + protected function resolve_file_path(string $filename): string { |
|
| 179 | + $filename = $this->maybe_resolve_dot_notation($filename); |
|
| 180 | 180 | return sprintf( |
| 181 | 181 | '%s%s.php', |
| 182 | 182 | $this->base_view_path, |
| 183 | - ltrim( $filename ) |
|
| 183 | + ltrim($filename) |
|
| 184 | 184 | ); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | * @param string $filename |
| 191 | 191 | * @return string |
| 192 | 192 | */ |
| 193 | - protected function maybe_resolve_dot_notation( string $filename ): string { |
|
| 194 | - if ( $this->str_ends_with( '.php', $filename ) ) { |
|
| 195 | - $filename = substr( $filename, 0, -4 ); |
|
| 193 | + protected function maybe_resolve_dot_notation(string $filename): string { |
|
| 194 | + if ($this->str_ends_with('.php', $filename)) { |
|
| 195 | + $filename = substr($filename, 0, -4); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $parts = explode( '.', $filename ); |
|
| 199 | - $filename = implode( DIRECTORY_SEPARATOR, $parts ); |
|
| 198 | + $parts = explode('.', $filename); |
|
| 199 | + $filename = implode(DIRECTORY_SEPARATOR, $parts); |
|
| 200 | 200 | |
| 201 | 201 | return $filename; |
| 202 | 202 | } |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * @param string $haystack |
| 209 | 209 | * @return bool |
| 210 | 210 | */ |
| 211 | - protected function str_ends_with( string $needle, string $haystack ): bool { |
|
| 212 | - $needle_len = strlen( $needle ); |
|
| 213 | - return ( $needle_len === 0 || 0 === substr_compare( $haystack, $needle, - $needle_len ) ); |
|
| 211 | + protected function str_ends_with(string $needle, string $haystack): bool { |
|
| 212 | + $needle_len = strlen($needle); |
|
| 213 | + return ($needle_len === 0 || 0 === substr_compare($haystack, $needle, - $needle_len)); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | * @return string |
| 222 | 222 | * @throws Exception |
| 223 | 223 | */ |
| 224 | - protected function verify_view_path( string $path ): string { |
|
| 225 | - $path = $this->maybe_resolve_dot_notation( $path ); |
|
| 226 | - $path = rtrim( $path, '/' ) . '/'; |
|
| 224 | + protected function verify_view_path(string $path): string { |
|
| 225 | + $path = $this->maybe_resolve_dot_notation($path); |
|
| 226 | + $path = rtrim($path, '/') . '/'; |
|
| 227 | 227 | |
| 228 | - if ( ! \is_dir( $path ) ) { |
|
| 229 | - throw new Exception( "{$path} doesn't exist and cant be used as the base view path." ); |
|
| 228 | + if ( ! \is_dir($path)) { |
|
| 229 | + throw new Exception("{$path} doesn't exist and cant be used as the base view path."); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | return $path; |