Completed
Push — master ( 02d85d...e7ad5b )
by Glynn
32s queued 14s
created
src/BladeOne_Provider.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types=1 );
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Implementation of BladeOne for the PinkCrab Perique frameworks Renderable interface
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @param PinkCrab_BladeOne $blade
58 58
 	 */
59
-	final public function __construct( PinkCrab_BladeOne $blade ) {
59
+	final public function __construct(PinkCrab_BladeOne $blade) {
60 60
 		static::$blade = $blade;
61 61
 	}
62 62
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		?string $compiled_path = null,
74 74
 		int $mode = 0
75 75
 	): self {
76
-		return new static( new PinkCrab_BladeOne( $template_path, $compiled_path, $mode ) );
76
+		return new static(new PinkCrab_BladeOne($template_path, $compiled_path, $mode));
77 77
 	}
78 78
 
79 79
 	/**
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @param string $esc
92 92
 	 * @return self
93 93
 	 */
94
-	public function set_esc_function( string $esc ): self {
95
-		static::$blade->set_esc_function( $esc );
94
+	public function set_esc_function(string $esc): self {
95
+		static::$blade->set_esc_function($esc);
96 96
 		return $this;
97 97
 	}
98 98
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param Component_Compiler $compiler
103 103
 	 * @return void
104 104
 	 */
105
-	public function set_component_compiler( Component_Compiler $compiler ): void {
105
+	public function set_component_compiler(Component_Compiler $compiler): void {
106 106
 		$this->component_compiler = $compiler;
107 107
 	}
108 108
 
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 	 * @param bool $print
115 115
 	 * @return void|string
116 116
 	 */
117
-	public function render( string $view, iterable $data, bool $print = true ) {
118
-		if ( $print ) {
119
-			print static::$blade->run( $view, (array) $data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
117
+	public function render(string $view, iterable $data, bool $print = true) {
118
+		if ($print) {
119
+			print static::$blade->run($view, (array) $data); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
120 120
 		} else {
121
-			return static::$blade->run( $view, (array) $data );
121
+			return static::$blade->run($view, (array) $data);
122 122
 		}
123 123
 	}
124 124
 
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param View_Model $view_model
129 129
 	 * @return string|void
130 130
 	 */
131
-	public function view_model( View_Model $view_model, bool $print = true ) {
132
-		return $this->render( str_replace( array( '/', '\\' ), '.', $view_model->template() ), $view_model->data(), $print );
131
+	public function view_model(View_Model $view_model, bool $print = true) {
132
+		return $this->render(str_replace(array('/', '\\'), '.', $view_model->template()), $view_model->data(), $print);
133 133
 	}
134 134
 
135 135
 		/**
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 	 * @param Component $component
139 139
 	 * @return string|void
140 140
 	 */
141
-	public function component( Component $component, bool $print = true ) {
141
+	public function component(Component $component, bool $print = true) {
142 142
 
143 143
 		// Throw exception of no compiler passed.
144
-		if ( ! is_a( $this->component_compiler, Component_Compiler::class ) ) {
145
-			throw new Exception( 'No component compiler passed to BladeOne' );
144
+		if ( ! is_a($this->component_compiler, Component_Compiler::class)) {
145
+			throw new Exception('No component compiler passed to BladeOne');
146 146
 		}
147 147
 
148 148
 		// Compile the component.
149
-		$compiled = $this->component_compiler->compile( $component );
150
-		return $this->render( str_replace( array( '/', '\\' ), '.', $compiled->template() ), $compiled->data(), $print );
149
+		$compiled = $this->component_compiler->compile($component);
150
+		return $this->render(str_replace(array('/', '\\'), '.', $compiled->template()), $compiled->data(), $print);
151 151
 	}
152 152
 
153 153
 	/**
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 	 * @return mixed
159 159
 	 * @throws BadMethodCallException
160 160
 	 */
161
-	public function __call( string $method, array $args = array() ) {
162
-		if ( ! $this->is_method( $method ) ) {
163
-			throw new BadMethodCallException( "{$method} is not a valid method on the BladeOne instance." );
161
+	public function __call(string $method, array $args = array()) {
162
+		if ( ! $this->is_method($method)) {
163
+			throw new BadMethodCallException("{$method} is not a valid method on the BladeOne instance.");
164 164
 		}
165 165
 
166
-		return static::$blade->{$method}( ...$args );
166
+		return static::$blade->{$method}(...$args);
167 167
 	}
168 168
 
169 169
 	/**
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 	 * @return mixed
175 175
 	 * @throws BadMethodCallException
176 176
 	 */
177
-	public static function __callStatic( string $method, array $args = array() ) {
178
-		if ( ! static::is_static_method( $method ) ) {
179
-			throw new BadMethodCallException( "{$method} is not a valid method on the BladeOne instance." );
177
+	public static function __callStatic(string $method, array $args = array()) {
178
+		if ( ! static::is_static_method($method)) {
179
+			throw new BadMethodCallException("{$method} is not a valid method on the BladeOne instance.");
180 180
 		}
181 181
 
182
-		return static::$blade::{$method}( ...$args );
182
+		return static::$blade::{$method}(...$args);
183 183
 	}
184 184
 
185 185
 	/**
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 * @param string $method
189 189
 	 * @return bool
190 190
 	 */
191
-	protected function is_method( string $method ): bool {
192
-		$class_reflection = new ReflectionClass( static::$blade );
191
+	protected function is_method(string $method): bool {
192
+		$class_reflection = new ReflectionClass(static::$blade);
193 193
 
194 194
 		// Check method exists.
195
-		if ( ! $class_reflection->hasMethod( $method ) ) {
195
+		if ( ! $class_reflection->hasMethod($method)) {
196 196
 			return false;
197 197
 		}
198 198
 
199
-		$method_reflection = $class_reflection->getMethod( $method );
199
+		$method_reflection = $class_reflection->getMethod($method);
200 200
 
201 201
 		return $method_reflection->isPublic() && ! $method_reflection->isStatic();
202 202
 	}
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
 	 * @param string $method
208 208
 	 * @return bool
209 209
 	 */
210
-	protected static function is_static_method( string $method ): bool {
211
-		$class_reflection = new ReflectionClass( static::$blade );
210
+	protected static function is_static_method(string $method): bool {
211
+		$class_reflection = new ReflectionClass(static::$blade);
212 212
 
213 213
 		// Check method exists.
214
-		if ( ! $class_reflection->hasMethod( $method ) ) {
214
+		if ( ! $class_reflection->hasMethod($method)) {
215 215
 			return false;
216 216
 		}
217 217
 
218
-		$method_reflection = $class_reflection->getMethod( $method );
218
+		$method_reflection = $class_reflection->getMethod($method);
219 219
 		return $method_reflection->isPublic() && $method_reflection->isStatic();
220 220
 	}
221 221
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param bool $bool
226 226
 	 * @return self
227 227
 	 */
228
-	public function allow_pipe( bool $bool = true ): self {
228
+	public function allow_pipe(bool $bool = true): self {
229 229
 		static::$blade->pipeEnable = $bool; //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
230 230
 		return $this;
231 231
 	}
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param callable $handler
238 238
 	 * @return self
239 239
 	 */
240
-	public function directive( string $name, callable $handler ): self {
241
-		static::$blade->directive( $name, $handler );
240
+	public function directive(string $name, callable $handler): self {
241
+		static::$blade->directive($name, $handler);
242 242
 		return $this;
243 243
 	}
244 244
 
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	 * @param callable $handler
250 250
 	 * @return self
251 251
 	 */
252
-	public function directive_rt( $name, callable $handler ): self {
253
-		static::$blade->directiveRT( $name, $handler );
252
+	public function directive_rt($name, callable $handler): self {
253
+		static::$blade->directiveRT($name, $handler);
254 254
 		return $this;
255 255
 	}
256 256
 
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	 * @param string|null $alias example "mynewop". If null then it uses the name of the template.
262 262
 	 * @return self
263 263
 	 */
264
-	public function add_include( $view, $alias = null ): self {
265
-		static::$blade->addInclude( $view, $alias );
264
+	public function add_include($view, $alias = null): self {
265
+		static::$blade->addInclude($view, $alias);
266 266
 		return $this;
267 267
 	}
268 268
 
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	 * @param string $class_with_namespace
274 274
 	 * @return self
275 275
 	 */
276
-	public function add_alias_classes( $alias_name, $class_with_namespace ): self {
277
-		static::$blade->addAliasClasses( $alias_name, $class_with_namespace );
276
+	public function add_alias_classes($alias_name, $class_with_namespace): self {
277
+		static::$blade->addAliasClasses($alias_name, $class_with_namespace);
278 278
 		return $this;
279 279
 	}
280 280
 
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * @param int $mode BladeOne::MODE_AUTO, BladeOne::MODE_DEBUG, BladeOne::MODE_FAST, BladeOne::MODE_SLOW
285 285
 	 * @return self
286 286
 	 */
287
-	public function set_mode( int $mode ): self {
288
-		static::$blade->setMode( $mode );
287
+	public function set_mode(int $mode): self {
288
+		static::$blade->setMode($mode);
289 289
 		return $this;
290 290
 	}
291 291
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param mixed        $value
304 304
 	 * @return $this
305 305
 	 */
306
-	public function share( $var_name, $value = null ): self {
307
-		static::$blade->share( $var_name, $value );
306
+	public function share($var_name, $value = null): self {
307
+		static::$blade->share($var_name, $value);
308 308
 		return $this;
309 309
 	}
310 310
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 * @param callable $function
315 315
 	 * @return $this
316 316
 	 */
317
-	public function set_inject_resolver( callable $function ): self {
318
-		static::$blade->setInjectResolver( $function );
317
+	public function set_inject_resolver(callable $function): self {
318
+		static::$blade->setInjectResolver($function);
319 319
 		return $this;
320 320
 	}
321 321
 
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	 * @param string $file_extension Example: .prefix.ext
327 327
 	 * @return $this
328 328
 	 */
329
-	public function set_file_extension( string $file_extension ): self {
330
-		static::$blade->setFileExtension( $file_extension );
329
+	public function set_file_extension(string $file_extension): self {
330
+		static::$blade->setFileExtension($file_extension);
331 331
 		return $this;
332 332
 	}
333 333
 
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	 * @param string $file_extension
339 339
 	 * @return $this
340 340
 	 */
341
-	public function set_compiled_extension( string $file_extension ): self {
342
-		static::$blade->setCompiledExtension( $file_extension );
341
+	public function set_compiled_extension(string $file_extension): self {
342
+		static::$blade->setCompiledExtension($file_extension);
343 343
 		return $this;
344 344
 	}
345 345
 
Please login to merge, or discard this patch.
src/Abstract_BladeOne_Config.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types=1 );
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Abstract class for configuring BladeOne
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param Hook_Loader $loader
45 45
 	 * @return void
46 46
 	 */
47
-	final public function register( Hook_Loader $loader ): void {
48
-		$loader->action( 'wp_loaded', array( $this, 'configure_blade_handler' ), 10, 2 );
47
+	final public function register(Hook_Loader $loader): void {
48
+		$loader->action('wp_loaded', array($this, 'configure_blade_handler'), 10, 2);
49 49
 	}
50 50
 
51 51
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param BladeOne_Provider $renderable
55 55
 	 * @return void
56 56
 	 */
57
-	public function set_renderable( BladeOne_Provider $renderable ): void {
57
+	public function set_renderable(BladeOne_Provider $renderable): void {
58 58
 		$this->renderable = $renderable;
59 59
 	}
60 60
 
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @return void
65 65
 	 */
66 66
 	final public function configure_blade_handler(): void {
67
-		if ( ! is_null( $this->renderable ) && is_a( $this->renderable, BladeOne_Provider::class ) ) {
68
-			$this->config( $this->renderable );
67
+		if ( ! is_null($this->renderable) && is_a($this->renderable, BladeOne_Provider::class)) {
68
+			$this->config($this->renderable);
69 69
 		}
70 70
 	}
71 71
 
@@ -75,5 +75,5 @@  discard block
 block discarded – undo
75 75
 	 * @param BladeOne_Provider $bladeone
76 76
 	 * @return void
77 77
 	 */
78
-	abstract public function config( BladeOne_Provider $bladeone): void;
78
+	abstract public function config(BladeOne_Provider $bladeone): void;
79 79
 }
Please login to merge, or discard this patch.
src/PinkCrab_BladeOne.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types=1 );
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Wrapper for BladeOne with HTML enabled
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
 	 * @param string          $compiled_path If null then it uses (caller_folder)/compiles
44 44
 	 * @param int             $mode         =[BladeOne::MODE_AUTO,BladeOne::MODE_DEBUG,BladeOne::MODE_FAST,BladeOne::MODE_SLOW][$i]
45 45
 	 */
46
-	public function __construct( $template_path = null, $compiled_path = null, $mode = 0 ) {
47
-		parent::__construct( $template_path, $compiled_path, $mode );
46
+	public function __construct($template_path = null, $compiled_path = null, $mode = 0) {
47
+		parent::__construct($template_path, $compiled_path, $mode);
48 48
 
49 49
 		// Add the viewModel directive.
50 50
 		$this->directiveRT(
51 51
 			'viewModel',
52
-			function( $expression ) {
53
-				return $this->view_model( $expression, true );
52
+			function($expression) {
53
+				return $this->view_model($expression, true);
54 54
 			}
55 55
 		);
56 56
 
57 57
 		// Add the component directive.
58 58
 		$this->directiveRT(
59 59
 			'component',
60
-			function( $expression ) {
61
-				return $this->component( $expression, true );
60
+			function($expression) {
61
+				return $this->component($expression, true);
62 62
 			}
63 63
 		);
64 64
 	}
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 	 * @param string $esc_function
85 85
 	 * @return void
86 86
 	 */
87
-	public function set_esc_function( string $esc_function ): void {
87
+	public function set_esc_function(string $esc_function): void {
88 88
 		// Throw exception if not a valid callable.
89
-		if ( ! \is_callable( $esc_function ) ) {
90
-			throw new \InvalidArgumentException( 'Invalid esc function provided.' );
89
+		if ( ! \is_callable($esc_function)) {
90
+			throw new \InvalidArgumentException('Invalid esc function provided.');
91 91
 		}
92 92
 
93 93
 		static::$esc_function = $esc_function;
94
-		$this->echoFormat     = sprintf( '\\%s(%%s)', $esc_function ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
94
+		$this->echoFormat     = sprintf('\\%s(%%s)', $esc_function); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
95 95
 	}
96 96
 
97 97
 	/**
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 	 * @param int|float|string|null|mixed[]|object $value
101 101
 	 * @return string
102 102
 	 */
103
-	public static function e( $value ): string {
104
-		if ( \is_null( $value ) ) {
103
+	public static function e($value): string {
104
+		if (\is_null($value)) {
105 105
 			return '';
106 106
 		}
107
-		if ( \is_array( $value ) || \is_object( $value ) ) {
108
-			return \call_user_func( static::$esc_function, \print_r( $value, true ) );//phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
107
+		if (\is_array($value) || \is_object($value)) {
108
+			return \call_user_func(static::$esc_function, \print_r($value, true)); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
109 109
 		}
110
-		if ( \is_numeric( $value ) ) {
110
+		if (\is_numeric($value)) {
111 111
 			$value = (string) $value;
112 112
 		}
113
-		return \call_user_func( static::$esc_function, $value );
113
+		return \call_user_func(static::$esc_function, $value);
114 114
 	}
115 115
 
116 116
 	/**
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 * @param bool $print
121 121
 	 * @return string|void
122 122
 	 */
123
-	public function component( Component $component, bool $print = true ) {
123
+	public function component(Component $component, bool $print = true) {
124 124
 		/** @var View */
125 125
 		$view = App::view();
126 126
 
127
-		return $view->component( $component, $print );
127
+		return $view->component($component, $print);
128 128
 	}
129 129
 
130 130
 	/**
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 * @param bool $print Print or Return the HTML
135 135
 	 * @return string|void
136 136
 	 */
137
-	public function view_model( View_Model $view_model, bool $print = true ) {
137
+	public function view_model(View_Model $view_model, bool $print = true) {
138 138
 		/** @var View */
139 139
 		$view = App::view();
140 140
 
141
-		return $view->view_model( $view_model, $print );
141
+		return $view->view_model($view_model, $print);
142 142
 	}
143 143
 
144 144
 
Please login to merge, or discard this patch.