Passed
Branch master (02d85d)
by Glynn
04:53
created
src/PinkCrab_BladeOne.php 1 patch
Spacing   +5 added lines, -5 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
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
 	 * @param bool $print
42 42
 	 * @return string|void
43 43
 	 */
44
-	public function component( Component $component, bool $print = true ) {
44
+	public function component(Component $component, bool $print = true) {
45 45
 		/** @var View */
46 46
 		$view = App::view();
47 47
 
48
-		return $view->component( $component, $print );
48
+		return $view->component($component, $print);
49 49
 	}
50 50
 
51 51
 	/**
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	 * @param bool $print Print or Return the HTML
56 56
 	 * @return string|void
57 57
 	 */
58
-	public function view_model( View_Model $view_model, bool $print = true ) {
58
+	public function view_model(View_Model $view_model, bool $print = true) {
59 59
 		/** @var View */
60 60
 		$view = App::view();
61 61
 
62
-		return $view->view_model( $view_model, $print );
62
+		return $view->view_model($view_model, $print);
63 63
 	}
64 64
 }
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
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	protected $renderable;
45 45
 
46
-	final public function register( Hook_Loader $loader ): void {
47
-		$loader->action( 'wp_loaded', array( $this, 'configure_blade_handler' ), 10, 2 );
46
+	final public function register(Hook_Loader $loader): void {
47
+		$loader->action('wp_loaded', array($this, 'configure_blade_handler'), 10, 2);
48 48
 	}
49 49
 
50 50
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @param BladeOne_Provider $renderable
54 54
 	 * @return void
55 55
 	 */
56
-	public function set_renderable( BladeOne_Provider $renderable ): void {
56
+	public function set_renderable(BladeOne_Provider $renderable): void {
57 57
 		$this->renderable = $renderable;
58 58
 	}
59 59
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @return void
64 64
 	 */
65 65
 	final public function configure_blade_handler(): void {
66
-		if ( ! is_null( $this->renderable ) && is_a( $this->renderable, BladeOne_Provider::class ) ) {
67
-			$this->config( $this->renderable );
66
+		if ( ! is_null($this->renderable) && is_a($this->renderable, BladeOne_Provider::class)) {
67
+			$this->config($this->renderable);
68 68
 		}
69 69
 	}
70 70
 
@@ -74,5 +74,5 @@  discard block
 block discarded – undo
74 74
 	 * @param BladeOne_Provider $bladeone
75 75
 	 * @return void
76 76
 	 */
77
-	abstract public function config( BladeOne_Provider $bladeone): void;
77
+	abstract public function config(BladeOne_Provider $bladeone): void;
78 78
 }
Please login to merge, or discard this patch.
src/BladeOne_Provider.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -122,11 +122,11 @@
 block discarded – undo
122 122
 	}
123 123
 
124 124
 		/**
125
-	 * Renders a component.
126
-	 *
127
-	 * @param Component $component
128
-	 * @return string|void
129
-	 */
125
+		 * Renders a component.
126
+		 *
127
+		 * @param Component $component
128
+		 * @return string|void
129
+		 */
130 130
 	public function component( Component $component, bool $print = true ) {
131 131
 
132 132
 		// Throw exception of no compiler passed.
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 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,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param Component_Compiler $compiler
92 92
 	 * @return void
93 93
 	 */
94
-	public function set_component_compiler( Component_Compiler $compiler ): void {
94
+	public function set_component_compiler(Component_Compiler $compiler): void {
95 95
 		$this->component_compiler = $compiler;
96 96
 	}
97 97
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @param bool $print
104 104
 	 * @return void|string
105 105
 	 */
106
-	public function render( string $view, iterable $data, bool $print = true ) {
107
-		if ( $print ) {
108
-			print static::$blade->run( $view, (array) $data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
106
+	public function render(string $view, iterable $data, bool $print = true) {
107
+		if ($print) {
108
+			print static::$blade->run($view, (array) $data); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
109 109
 		} else {
110
-			return static::$blade->run( $view, (array) $data );
110
+			return static::$blade->run($view, (array) $data);
111 111
 		}
112 112
 	}
113 113
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 * @param View_Model $view_model
118 118
 	 * @return string|void
119 119
 	 */
120
-	public function view_model( View_Model $view_model, bool $print = true ) {
121
-		return $this->render( str_replace( array( '/', '\\' ), '.', $view_model->template() ), $view_model->data(), $print );
120
+	public function view_model(View_Model $view_model, bool $print = true) {
121
+		return $this->render(str_replace(array('/', '\\'), '.', $view_model->template()), $view_model->data(), $print);
122 122
 	}
123 123
 
124 124
 		/**
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	 * @param Component $component
128 128
 	 * @return string|void
129 129
 	 */
130
-	public function component( Component $component, bool $print = true ) {
130
+	public function component(Component $component, bool $print = true) {
131 131
 
132 132
 		// Throw exception of no compiler passed.
133
-		if ( ! is_a( $this->component_compiler, Component_Compiler::class ) ) {
134
-			throw new Exception( 'No component compiler passed to BladeOne' );
133
+		if ( ! is_a($this->component_compiler, Component_Compiler::class)) {
134
+			throw new Exception('No component compiler passed to BladeOne');
135 135
 		}
136 136
 
137 137
 		// Compile the component.
138
-		$compiled = $this->component_compiler->compile( $component );
139
-		return $this->render( str_replace( array( '/', '\\' ), '.', $compiled->template() ), $compiled->data(), $print );
138
+		$compiled = $this->component_compiler->compile($component);
139
+		return $this->render(str_replace(array('/', '\\'), '.', $compiled->template()), $compiled->data(), $print);
140 140
 	}
141 141
 
142 142
 	/**
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	 * @return mixed
148 148
 	 * @throws BadMethodCallException
149 149
 	 */
150
-	public function __call( string $method, array $args = array() ) {
151
-		if ( ! $this->is_method( $method ) ) {
152
-			throw new BadMethodCallException( "{$method} is not a valid method on the BladeOne instance." );
150
+	public function __call(string $method, array $args = array()) {
151
+		if ( ! $this->is_method($method)) {
152
+			throw new BadMethodCallException("{$method} is not a valid method on the BladeOne instance.");
153 153
 		}
154 154
 
155
-		return static::$blade->{$method}( ...$args );
155
+		return static::$blade->{$method}(...$args);
156 156
 	}
157 157
 
158 158
 	/**
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 	 * @return mixed
164 164
 	 * @throws BadMethodCallException
165 165
 	 */
166
-	public static function __callStatic( string $method, array $args = array() ) {
167
-		if ( ! static::is_static_method( $method ) ) {
168
-			throw new BadMethodCallException( "{$method} is not a valid method on the BladeOne instance." );
166
+	public static function __callStatic(string $method, array $args = array()) {
167
+		if ( ! static::is_static_method($method)) {
168
+			throw new BadMethodCallException("{$method} is not a valid method on the BladeOne instance.");
169 169
 		}
170 170
 
171
-		return static::$blade::{$method}( ...$args );
171
+		return static::$blade::{$method}(...$args);
172 172
 	}
173 173
 
174 174
 	/**
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 	 * @param string $method
178 178
 	 * @return bool
179 179
 	 */
180
-	protected function is_method( string $method ): bool {
181
-		$class_reflection = new ReflectionClass( static::$blade );
180
+	protected function is_method(string $method): bool {
181
+		$class_reflection = new ReflectionClass(static::$blade);
182 182
 
183 183
 		// Check method exists.
184
-		if ( ! $class_reflection->hasMethod( $method ) ) {
184
+		if ( ! $class_reflection->hasMethod($method)) {
185 185
 			return false;
186 186
 		}
187 187
 
188
-		$method_reflection = $class_reflection->getMethod( $method );
188
+		$method_reflection = $class_reflection->getMethod($method);
189 189
 
190 190
 		return $method_reflection->isPublic() && ! $method_reflection->isStatic();
191 191
 	}
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
 	 * @param string $method
197 197
 	 * @return bool
198 198
 	 */
199
-	protected static function is_static_method( string $method ): bool {
200
-		$class_reflection = new ReflectionClass( static::$blade );
199
+	protected static function is_static_method(string $method): bool {
200
+		$class_reflection = new ReflectionClass(static::$blade);
201 201
 
202 202
 		// Check method exists.
203
-		if ( ! $class_reflection->hasMethod( $method ) ) {
203
+		if ( ! $class_reflection->hasMethod($method)) {
204 204
 			return false;
205 205
 		}
206 206
 
207
-		$method_reflection = $class_reflection->getMethod( $method );
207
+		$method_reflection = $class_reflection->getMethod($method);
208 208
 		return $method_reflection->isPublic() && $method_reflection->isStatic();
209 209
 	}
210 210
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @param bool $bool
215 215
 	 * @return self
216 216
 	 */
217
-	public function allow_pipe( bool $bool = true ): self {
217
+	public function allow_pipe(bool $bool = true): self {
218 218
 		static::$blade->pipeEnable = $bool; //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
219 219
 		return $this;
220 220
 	}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param callable $handler
227 227
 	 * @return self
228 228
 	 */
229
-	public function directive( string $name, callable $handler ): self {
230
-		static::$blade->directive( $name, $handler );
229
+	public function directive(string $name, callable $handler): self {
230
+		static::$blade->directive($name, $handler);
231 231
 		return $this;
232 232
 	}
233 233
 
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * @param callable $handler
239 239
 	 * @return self
240 240
 	 */
241
-	public function directive_rt( $name, callable $handler ): self {
242
-		static::$blade->directiveRT( $name, $handler );
241
+	public function directive_rt($name, callable $handler): self {
242
+		static::$blade->directiveRT($name, $handler);
243 243
 		return $this;
244 244
 	}
245 245
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	 * @param string|null $alias example "mynewop". If null then it uses the name of the template.
251 251
 	 * @return self
252 252
 	 */
253
-	public function add_include( $view, $alias = null ): self {
254
-		static::$blade->addInclude( $view, $alias );
253
+	public function add_include($view, $alias = null): self {
254
+		static::$blade->addInclude($view, $alias);
255 255
 		return $this;
256 256
 	}
257 257
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * @param string $class_with_namespace
263 263
 	 * @return self
264 264
 	 */
265
-	public function add_alias_classes( $alias_name, $class_with_namespace ): self {
266
-		static::$blade->addAliasClasses( $alias_name, $class_with_namespace );
265
+	public function add_alias_classes($alias_name, $class_with_namespace): self {
266
+		static::$blade->addAliasClasses($alias_name, $class_with_namespace);
267 267
 		return $this;
268 268
 	}
269 269
 
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	 * @param int $mode BladeOne::MODE_AUTO, BladeOne::MODE_DEBUG, BladeOne::MODE_FAST, BladeOne::MODE_SLOW
274 274
 	 * @return self
275 275
 	 */
276
-	public function set_mode( int $mode ): self {
277
-		static::$blade->setMode( $mode );
276
+	public function set_mode(int $mode): self {
277
+		static::$blade->setMode($mode);
278 278
 		return $this;
279 279
 	}
280 280
 
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param mixed        $value
293 293
 	 * @return $this
294 294
 	 */
295
-	public function share( $var_name, $value = null ): self {
296
-		static::$blade->share( $var_name, $value );
295
+	public function share($var_name, $value = null): self {
296
+		static::$blade->share($var_name, $value);
297 297
 		return $this;
298 298
 	}
299 299
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param callable $function
304 304
 	 * @return $this
305 305
 	 */
306
-	public function set_inject_resolver( callable $function ): self {
307
-		static::$blade->setInjectResolver( $function );
306
+	public function set_inject_resolver(callable $function): self {
307
+		static::$blade->setInjectResolver($function);
308 308
 		return $this;
309 309
 	}
310 310
 
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 	 * @param string $file_extension Example: .prefix.ext
316 316
 	 * @return $this
317 317
 	 */
318
-	public function set_file_extension( string $file_extension ): self {
319
-		static::$blade->setFileExtension( $file_extension );
318
+	public function set_file_extension(string $file_extension): self {
319
+		static::$blade->setFileExtension($file_extension);
320 320
 		return $this;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param string $file_extension
328 328
 	 * @return $this
329 329
 	 */
330
-	public function set_compiled_extension( string $file_extension ): self {
331
-		static::$blade->setCompiledExtension( $file_extension );
330
+	public function set_compiled_extension(string $file_extension): self {
331
+		static::$blade->setCompiledExtension($file_extension);
332 332
 		return $this;
333 333
 	}
334 334
 
Please login to merge, or discard this patch.
src/BladeOne_Bootstrap.php 1 patch
Spacing   +19 added lines, -19 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
@@ -44,39 +44,39 @@  discard block
 block discarded – undo
44 44
 	 * @param class-string|BladeOne $blade
45 45
 	 * @return void
46 46
 	 */
47
-	public static function use( $template_path = null, ?string $compiled_path = null, int $mode = 0, $blade = null ) {
47
+	public static function use($template_path = null, ?string $compiled_path = null, int $mode = 0, $blade = null) {
48 48
 
49 49
 		add_filter(
50 50
 			Hooks::APP_INIT_SET_DI_RULES,
51
-			function( $rules ) use ( $template_path, $compiled_path, $mode, $blade ) {
51
+			function($rules) use ($template_path, $compiled_path, $mode, $blade) {
52 52
 				// Unset the global PHP_Engine useage.
53
-				if ( array_key_exists( '*', $rules )
54
-				&& array_key_exists( 'substitutions', $rules['*'] )
55
-				&& array_key_exists( Renderable::class, $rules['*']['substitutions'] )
56
-				&& is_a( $rules['*']['substitutions'][ Renderable::class ], PHP_Engine::class ) ) {
57
-					unset( $rules['*']['substitutions'][ Renderable::class ] );
53
+				if (array_key_exists('*', $rules)
54
+				&& array_key_exists('substitutions', $rules['*'])
55
+				&& array_key_exists(Renderable::class, $rules['*']['substitutions'])
56
+				&& is_a($rules['*']['substitutions'][Renderable::class], PHP_Engine::class)) {
57
+					unset($rules['*']['substitutions'][Renderable::class]);
58 58
 				}
59 59
 
60 60
 				// Get the version of Blade to start.
61
-				$blade = self::get_blade_instance( $blade );
61
+				$blade = self::get_blade_instance($blade);
62 62
 
63
-				$rules[ BladeOne_Provider::class ] = array(
63
+				$rules[BladeOne_Provider::class] = array(
64 64
 					'substitutions' => array(
65
-						PinkCrab_BladeOne::class => new $blade( $template_path, $compiled_path, $mode ),
65
+						PinkCrab_BladeOne::class => new $blade($template_path, $compiled_path, $mode),
66 66
 					),
67 67
 					'call'          => array(
68
-						array( 'allow_pipe', array() ),
68
+						array('allow_pipe', array()),
69 69
 					),
70 70
 				);
71 71
 
72
-				$rules[ Renderable::class ] = array(
72
+				$rules[Renderable::class] = array(
73 73
 					'instanceOf' => BladeOne_Provider::class,
74 74
 					'shared'     => true,
75 75
 				);
76 76
 
77
-				$rules[ Abstract_BladeOne_Config::class ] = array(
77
+				$rules[Abstract_BladeOne_Config::class] = array(
78 78
 					'call' => array(
79
-						array( 'set_renderable', array( array( Dice::INSTANCE => Renderable::class ) ) ),
79
+						array('set_renderable', array(array(Dice::INSTANCE => Renderable::class))),
80 80
 					),
81 81
 				);
82 82
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	 * @param mixed $blade
92 92
 	 * @return class-string
93 93
 	 */
94
-	protected static function get_blade_instance( $blade ): string {
94
+	protected static function get_blade_instance($blade): string {
95 95
 		// If we have a populated instance of BladeOne, get the full class name.
96
-		if ( is_object( $blade ) && is_a( $blade, PinkCrab_BladeOne::class ) ) {
97
-			$blade = get_class( $blade );
96
+		if (is_object($blade) && is_a($blade, PinkCrab_BladeOne::class)) {
97
+			$blade = get_class($blade);
98 98
 		}
99 99
 
100
-		if ( is_string( $blade ) && is_a( $blade, PinkCrab_BladeOne::class, true ) ) {
100
+		if (is_string($blade) && is_a($blade, PinkCrab_BladeOne::class, true)) {
101 101
 			return $blade;
102 102
 		}
103 103
 
Please login to merge, or discard this patch.