Test Failed
Push — master ( d9e6c6...a05c02 )
by Alain
05:54
created
src/DependencyManager.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @var array;
52 52
 	 */
53
-	protected $dependencies = [ ];
53
+	protected $dependencies = [];
54 54
 
55 55
 	/**
56 56
 	 * Hold the handlers.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var DependencyHandlerInterface[]
61 61
 	 */
62
-	protected $handlers = [ ];
62
+	protected $handlers = [];
63 63
 
64 64
 	/**
65 65
 	 * Whether to enqueue immediately upon registration.
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * @throws InvalidArgumentException If no dependency handlers were
84 84
 	 *                                  specified.
85 85
 	 */
86
-	public function __construct( ConfigInterface $config, $enqueue = true ) {
87
-		$this->processConfig( $config );
86
+	public function __construct(ConfigInterface $config, $enqueue = true) {
87
+		$this->processConfig($config);
88 88
 		$this->enqueue_immediately = $enqueue;
89 89
 		$this->init_handlers();
90 90
 		$this->init_dependencies();
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 * @since 0.1.0
97 97
 	 */
98 98
 	protected function init_handlers() {
99
-		$keys = [ self::KEY_SCRIPTS, self::KEY_STYLES ];
100
-		foreach ( $keys as $key ) {
101
-			if ( $this->hasConfigKey( $key ) ) {
102
-				$this->add_handler( $key );
99
+		$keys = [self::KEY_SCRIPTS, self::KEY_STYLES];
100
+		foreach ($keys as $key) {
101
+			if ($this->hasConfigKey($key)) {
102
+				$this->add_handler($key);
103 103
 			}
104 104
 		}
105 105
 	}
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param string $dependency The dependency type for which to add a handler.
113 113
 	 */
114
-	protected function add_handler( $dependency ) {
115
-		if ( $this->hasConfigKey( $dependency ) ) {
116
-			$handler = $this->hasConfigKey( self::KEY_HANDLERS, $dependency )
117
-				? $this->getConfigKey( self::KEY_HANDLERS, $dependency )
118
-				: $this->get_default_handler( $dependency );
119
-			if ( $handler ) {
120
-				$this->handlers[ $dependency ] = new $handler;
114
+	protected function add_handler($dependency) {
115
+		if ($this->hasConfigKey($dependency)) {
116
+			$handler = $this->hasConfigKey(self::KEY_HANDLERS, $dependency)
117
+				? $this->getConfigKey(self::KEY_HANDLERS, $dependency)
118
+				: $this->get_default_handler($dependency);
119
+			if ($handler) {
120
+				$this->handlers[$dependency] = new $handler;
121 121
 			}
122 122
 		}
123 123
 	}
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	 * @param string $dependency The dependency that needs a handler.
131 131
 	 * @return string|null Class name of the handler. Null if none.
132 132
 	 */
133
-	protected function get_default_handler( $dependency ) {
134
-		switch ( $dependency ) {
133
+	protected function get_default_handler($dependency) {
134
+		switch ($dependency) {
135 135
 			case self::KEY_STYLES:
136 136
 				return self::DEFAULT_STYLE_HANDLER;
137 137
 			case self::KEY_SCRIPTS:
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 * @since 0.1.0
148 148
 	 */
149 149
 	protected function init_dependencies() {
150
-		array_walk( $this->handlers,
151
-			function ( $handler, $dependency_type ) {
152
-				if ( $this->hasConfigKey( $dependency_type ) ) {
153
-					$this->dependencies[ $dependency_type ] = $this->init_dependency_type( $dependency_type );
150
+		array_walk($this->handlers,
151
+			function($handler, $dependency_type) {
152
+				if ($this->hasConfigKey($dependency_type)) {
153
+					$this->dependencies[$dependency_type] = $this->init_dependency_type($dependency_type);
154 154
 				}
155 155
 			} );
156 156
 	}
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 	 * @param string $type The type of dependency to initialize.
164 164
 	 * @return array Array of dependency configurations.
165 165
 	 */
166
-	protected function init_dependency_type( $type ) {
167
-		$array = [ ];
168
-		$data  = $this->getConfigKey( $type );
169
-		foreach ( $data as $dependency ) {
170
-			$handle           = array_key_exists( 'handle',
171
-				$dependency ) ? $dependency['handle'] : '';
172
-			$array[ $handle ] = $dependency;
166
+	protected function init_dependency_type($type) {
167
+		$array = [];
168
+		$data  = $this->getConfigKey($type);
169
+		foreach ($data as $dependency) {
170
+			$handle           = array_key_exists('handle',
171
+				$dependency) ? $dependency['handle'] : '';
172
+			$array[$handle] = $dependency;
173 173
 		}
174 174
 		return $array;
175 175
 	}
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param mixed $context Optional. The context to pass to the dependencies.
183 183
 	 */
184
-	public function register( $context = null ) {
185
-		$context = $this->validate_context( $context );
186
-		array_walk( $this->dependencies,
187
-			[ $this, 'register_dependency_type' ], $context );
184
+	public function register($context = null) {
185
+		$context = $this->validate_context($context);
186
+		array_walk($this->dependencies,
187
+			[$this, 'register_dependency_type'], $context);
188 188
 	}
189 189
 
190 190
 	/**
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 * @param mixed $context The context as passed in by WordPress.
196 196
 	 * @return array Validated context.
197 197
 	 */
198
-	protected function validate_context( $context ) {
199
-		if ( is_string( $context ) ) {
200
-			return [ 'wp_context' => $context ];
198
+	protected function validate_context($context) {
199
+		if (is_string($context)) {
200
+			return ['wp_context' => $context];
201 201
 		}
202 202
 		return (array) $context;
203 203
 	}
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 	 * @param mixed $context  Optional. The context to pass to the
211 211
 	 *                        dependencies.
212 212
 	 */
213
-	public function enqueue( $context = null ) {
214
-		$context = $this->validate_context( $context );
213
+	public function enqueue($context = null) {
214
+		$context = $this->validate_context($context);
215 215
 
216
-		array_walk( $this->dependencies,
217
-			[ $this, 'enqueue_dependency_type' ], $context );
216
+		array_walk($this->dependencies,
217
+			[$this, 'enqueue_dependency_type'], $context);
218 218
 	}
219 219
 
220 220
 	/**
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 *                         outside of DependencyManager. Defaults to false.
230 230
 	 * @return bool Returns whether the handle was found or not.
231 231
 	 */
232
-	public function enqueue_handle( $handle, $context = null, $fallback = false ) {
233
-		if ( ! $this->enqueue_internal_handle( $handle, $context ) ) {
234
-			return $this->enqueue_fallback_handle( $handle );
232
+	public function enqueue_handle($handle, $context = null, $fallback = false) {
233
+		if ( ! $this->enqueue_internal_handle($handle, $context)) {
234
+			return $this->enqueue_fallback_handle($handle);
235 235
 		}
236 236
 		return true;
237 237
 	}
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 	 *                         dependencies.
248 248
 	 * @return bool Returns whether the handle was found or not.
249 249
 	 */
250
-	protected function enqueue_internal_handle( $handle, $context = null ) {
251
-		list( $dependency_type, $dependency ) = $this->get_dependency_array( $handle );
250
+	protected function enqueue_internal_handle($handle, $context = null) {
251
+		list($dependency_type, $dependency) = $this->get_dependency_array($handle);
252 252
 		$context['dependency_type'] = $dependency_type;
253 253
 
254
-		if ( ! $dependency ) {
254
+		if ( ! $dependency) {
255 255
 			return false;
256 256
 		}
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$context
262 262
 		);
263 263
 
264
-		$this->maybe_localize( $dependency, $context );
264
+		$this->maybe_localize($dependency, $context);
265 265
 
266 266
 		return true;
267 267
 	}
@@ -275,14 +275,14 @@  discard block
 block discarded – undo
275 275
 	 * @return array Array containing the dependency key as well as the
276 276
 	 *                       dependency array itself.
277 277
 	 */
278
-	protected function get_dependency_array( $handle ) {
279
-		foreach ( $this->dependencies as $type => $dependencies ) {
280
-			if ( array_key_exists( $handle, $dependencies ) ) {
281
-				return [ $type, $dependencies[ $handle ] ];
278
+	protected function get_dependency_array($handle) {
279
+		foreach ($this->dependencies as $type => $dependencies) {
280
+			if (array_key_exists($handle, $dependencies)) {
281
+				return [$type, $dependencies[$handle]];
282 282
 			}
283 283
 		}
284 284
 		// Handle not found, return an empty array.
285
-		return [ '', null ];
285
+		return ['', null];
286 286
 	}
287 287
 
288 288
 	/**
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	 *                               dependency at key
298 298
 	 *                               'dependency_type'.
299 299
 	 */
300
-	protected function enqueue_dependency( $dependency, $dependency_key, $context = null ) {
301
-		if ( ! $this->is_needed( $dependency, $context ) ) {
300
+	protected function enqueue_dependency($dependency, $dependency_key, $context = null) {
301
+		if ( ! $this->is_needed($dependency, $context)) {
302 302
 			return;
303 303
 		}
304
-		$handler = $this->handlers[ $context['dependency_type'] ];
305
-		$handler->enqueue( $dependency );
304
+		$handler = $this->handlers[$context['dependency_type']];
305
+		$handler->enqueue($dependency);
306 306
 	}
307 307
 
308 308
 	/**
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 	 *                          'dependency_type'.
317 317
 	 * @return bool Whether it is needed or not.
318 318
 	 */
319
-	protected function is_needed( $dependency, $context ) {
320
-		$is_needed = array_key_exists( 'is_needed', $dependency )
319
+	protected function is_needed($dependency, $context) {
320
+		$is_needed = array_key_exists('is_needed', $dependency)
321 321
 			? $dependency['is_needed']
322 322
 			: null;
323 323
 
324
-		if ( null === $is_needed ) {
324
+		if (null === $is_needed) {
325 325
 			return true;
326 326
 		}
327 327
 
328
-		return is_callable( $is_needed ) && $is_needed( $context );
328
+		return is_callable($is_needed) && $is_needed($context);
329 329
 	}
330 330
 
331 331
 	/**
@@ -338,18 +338,18 @@  discard block
 block discarded – undo
338 338
 	 *                          Contains the type of the dependency at key
339 339
 	 *                          'dependency_type'.
340 340
 	 */
341
-	protected function maybe_localize( $dependency, $context ) {
342
-		if ( ! array_key_exists( 'localize', $dependency ) ) {
341
+	protected function maybe_localize($dependency, $context) {
342
+		if ( ! array_key_exists('localize', $dependency)) {
343 343
 			return;
344 344
 		}
345 345
 
346 346
 		$localize = $dependency['localize'];
347 347
 		$data     = $localize['data'];
348
-		if ( is_callable( $data ) ) {
349
-			$data = $data( $context );
348
+		if (is_callable($data)) {
349
+			$data = $data($context);
350 350
 		}
351 351
 
352
-		wp_localize_script( $dependency['handle'], $localize['name'], $data );
352
+		wp_localize_script($dependency['handle'], $localize['name'], $data);
353 353
 	}
354 354
 
355 355
 	/**
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 	 * @param string $handle The dependency handle to enqueue.
362 362
 	 * @return bool Returns whether the handle was found or not.
363 363
 	 */
364
-	protected function enqueue_fallback_handle( $handle ) {
364
+	protected function enqueue_fallback_handle($handle) {
365 365
 		$result = false;
366
-		foreach ( $this->handlers as $handler ) {
367
-			$result = $result || $handler->maybe_enqueue( $handle );
366
+		foreach ($this->handlers as $handler) {
367
+			$result = $result || $handler->maybe_enqueue($handle);
368 368
 		}
369 369
 		return $result;
370 370
 	}
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
 	 * @param mixed  $context         Optional. The context to pass to the
380 380
 	 *                                dependencies.
381 381
 	 */
382
-	protected function enqueue_dependency_type( $dependencies, $dependency_type, $context = null ) {
382
+	protected function enqueue_dependency_type($dependencies, $dependency_type, $context = null) {
383 383
 		$context['dependency_type'] = $dependency_type;
384
-		array_walk( $dependencies, [ $this, 'enqueue_dependency' ], $context );
384
+		array_walk($dependencies, [$this, 'enqueue_dependency'], $context);
385 385
 	}
386 386
 
387 387
 	/**
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 	 * @param mixed  $context         Optional. The context to pass to the
395 395
 	 *                                dependencies.
396 396
 	 */
397
-	protected function register_dependency_type( $dependencies, $dependency_type, $context = null ) {
397
+	protected function register_dependency_type($dependencies, $dependency_type, $context = null) {
398 398
 		$context['dependency_type'] = $dependency_type;
399
-		array_walk( $dependencies, [ $this, 'register_dependency' ], $context );
399
+		array_walk($dependencies, [$this, 'register_dependency'], $context);
400 400
 	}
401 401
 
402 402
 	/**
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 	 *                               dependency at key
412 412
 	 *                               'dependency_type'.
413 413
 	 */
414
-	protected function register_dependency( $dependency, $dependency_key, $context = null ) {
415
-		$handler = $this->handlers[ $context['dependency_type'] ];
416
-		$handler->register( $dependency );
414
+	protected function register_dependency($dependency, $dependency_key, $context = null) {
415
+		$handler = $this->handlers[$context['dependency_type']];
416
+		$handler->register($dependency);
417 417
 
418
-		if ( $this->enqueue_immediately ) {
419
-			$this->register_enqueue_hooks( $dependency, $context );
418
+		if ($this->enqueue_immediately) {
419
+			$this->register_enqueue_hooks($dependency, $context);
420 420
 		}
421 421
 	}
422 422
 
@@ -430,14 +430,14 @@  discard block
 block discarded – undo
430 430
 	 *                          Contains the type of the dependency at key
431 431
 	 *                          'dependency_type'.
432 432
 	 */
433
-	protected function register_enqueue_hooks( $dependency, $context = null ) {
434
-		$priority = $this->get_priority( $dependency );
433
+	protected function register_enqueue_hooks($dependency, $context = null) {
434
+		$priority = $this->get_priority($dependency);
435 435
 
436
-		foreach ( [ 'wp_enqueue_scripts', 'admin_enqueue_scripts' ] as $hook ) {
437
-			add_action( $hook, [ $this, 'enqueue' ], $priority, 1 );
436
+		foreach (['wp_enqueue_scripts', 'admin_enqueue_scripts'] as $hook) {
437
+			add_action($hook, [$this, 'enqueue'], $priority, 1);
438 438
 		}
439 439
 
440
-		$this->maybe_localize( $dependency, $context );
440
+		$this->maybe_localize($dependency, $context);
441 441
 	}
442 442
 
443 443
 	/**
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
 	 * @param array $dependency Configuration data of the dependency.
449 449
 	 * @return int Priority to use.
450 450
 	 */
451
-	protected function get_priority( $dependency ) {
452
-		if ( array_key_exists( 'priority', $dependency ) ) {
453
-			return intval( $dependency['priority'] );
451
+	protected function get_priority($dependency) {
452
+		if (array_key_exists('priority', $dependency)) {
453
+			return intval($dependency['priority']);
454 454
 		}
455 455
 		return 10;
456 456
 	}
Please login to merge, or discard this patch.
src/StyleHandler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@
 block discarded – undo
41 41
 	 * @param string $handle The handle to check
42 42
 	 * @return bool Whether it is registered or not.
43 43
 	 */
44
-	protected function is_registered( $handle ) {
45
-		return wp_style_is( $handle, 'registered' );
44
+	protected function is_registered($handle) {
45
+		return wp_style_is($handle, 'registered');
46 46
 	}
47 47
 
48 48
 	/**
Please login to merge, or discard this patch.
src/AbstractDependencyHandler.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * @throws InvalidArgumentException If the register function could not be
36 36
 	 *                                  called.
37 37
 	 */
38
-	public function register( $args = null ) {
39
-		$this->invokeFunction( $this->get_register_function(), (array) $args );
38
+	public function register($args = null) {
39
+		$this->invokeFunction($this->get_register_function(), (array) $args);
40 40
 	}
41 41
 
42 42
 	/**
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 * @throws InvalidArgumentException If the register function could not be
59 59
 	 *                                  called.
60 60
 	 */
61
-	public function enqueue( $args = null ) {
62
-		$this->invokeFunction( $this->get_enqueue_function(), (array) $args );
61
+	public function enqueue($args = null) {
62
+		$this->invokeFunction($this->get_enqueue_function(), (array) $args);
63 63
 	}
64 64
 
65 65
 	/**
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 * @param string $handle Handle of the dependency to enqueue.
81 81
 	 * @return bool Whether the handle was found or not.
82 82
 	 */
83
-	public function maybe_enqueue( $handle ) {
84
-		if ( $this->is_registered( $handle ) ) {
83
+	public function maybe_enqueue($handle) {
84
+		if ($this->is_registered($handle)) {
85 85
 			$enqueue = $this->get_enqueue_function();
86
-			$enqueue( $handle );
86
+			$enqueue($handle);
87 87
 			return true;
88 88
 		}
89 89
 		return false;
@@ -97,5 +97,5 @@  discard block
 block discarded – undo
97 97
 	 * @param string $handle The handle to check
98 98
 	 * @return bool Whether it is registered or not.
99 99
 	 */
100
-	abstract protected function is_registered( $handle );
100
+	abstract protected function is_registered($handle);
101 101
 }
Please login to merge, or discard this patch.
src/ScriptHandler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @param string $handle The handle to check
51 51
 	 * @return bool Whether it is registered or not.
52 52
 	 */
53
-	protected function is_registered( $handle ) {
54
-		return wp_script_is( $handle, 'registered' );
53
+	protected function is_registered($handle) {
54
+		return wp_script_is($handle, 'registered');
55 55
 	}
56 56
 }
Please login to merge, or discard this patch.