Test Failed
Push — master ( 2c95af...0de91d )
by Alain
04:14
created

ScriptHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 49
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_register_function() 0 3 1
A get_enqueue_function() 0 3 1
A is_registered() 0 3 1
A is_enqueued() 0 3 1
1
<?php
2
/**
3
 * Bright Nucleus Dependency Component.
4
 *
5
 * @package   BrightNucleus\Dependency
6
 * @author    Alain Schlesser <[email protected]>
7
 * @license   MIT
8
 * @link      http://www.brightnucleus.com/
9
 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
 */
11
12
namespace BrightNucleus\Dependency;
13
14
/**
15
 * Class ScriptHandler.
16
 *
17
 * @since   0.1.0
18
 *
19
 * @package BrightNucleus\Dependency
20
 */
21
class ScriptHandler extends AbstractDependencyHandler {
22
23
	/**
24
	 * Get the name of the function that is used for registering the dependency.
25
	 *
26
	 * @since 0.1.0
27
	 *
28
	 * @return string Function name.
29
	 */
30
	protected function get_register_function() {
31
		return 'wp_register_script';
32
	}
33
34
	/**
35
	 * Get the name of the function that is used for enqueueing the dependency.
36
	 *
37
	 * @since 0.1.0
38
	 *
39
	 * @return string Function name.
40
	 */
41
	protected function get_enqueue_function() {
42
		return 'wp_enqueue_script';
43
	}
44
45
	/**
46
	 * Check whether a specific handle has been registered.
47
	 *
48
	 * @since 0.2.3
49
	 * @since 0.3.3 Publicly accessible.
50
	 *
51
	 * @param string $handle The handle to check
52
	 * @return bool Whether it is registered or not.
53
	 */
54
	public function is_registered( $handle ) {
55
		return wp_script_is( $handle, 'registered' );
56
	}
57
58
	/**
59
	 * Check whether a specific handle has been enqueued.
60
	 *
61
	 * @since 0.3.3
62
	 *
63
	 * @param string $handle The handle to check
64
	 * @return bool Whether it is enqueued or not.
65
	 */
66
	public function is_enqueued( $handle ) {
67
		return wp_script_is( $handle, 'enqueued' );
68
	}
69
}
70