_WP_Dependency   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A add_data() 0 6 2
1
<?php
2
/**
3
 * Dependencies API: _WP_Dependency class
4
 *
5
 * @since 4.7.0
6
 *
7
 * @package WordPress
8
 * @subpackage Dependencies
9
 */
10
11
/**
12
 * Class _WP_Dependency
13
 *
14
 * Helper class to register a handle and associated data.
15
 *
16
 * @access private
17
 * @since 2.6.0
18
 */
19
class _WP_Dependency {
20
	/**
21
	 * The handle name.
22
	 *
23
	 * @access public
24
	 * @since 2.6.0
25
	 * @var null
26
	 */
27
	public $handle;
28
29
	/**
30
	 * The handle source.
31
	 *
32
	 * @access public
33
	 * @since 2.6.0
34
	 * @var null
35
	 */
36
	public $src;
37
38
	/**
39
	 * An array of handle dependencies.
40
	 *
41
	 * @access public
42
	 * @since 2.6.0
43
	 * @var array
44
	 */
45
	public $deps = array();
46
47
	/**
48
	 * The handle version.
49
	 *
50
	 * Used for cache-busting.
51
	 *
52
	 * @access public
53
	 * @since 2.6.0
54
	 * @var bool|string
55
	 */
56
	public $ver = false;
57
58
	/**
59
	 * Additional arguments for the handle.
60
	 *
61
	 * @access public
62
	 * @since 2.6.0
63
	 * @var null
64
	 */
65
	public $args = null;  // Custom property, such as $in_footer or $media.
66
67
	/**
68
	 * Extra data to supply to the handle.
69
	 *
70
	 * @access public
71
	 * @since 2.6.0
72
	 * @var array
73
	 */
74
	public $extra = array();
75
76
	/**
77
	 * Setup dependencies.
78
	 *
79
	 * @since 2.6.0
80
	 */
81
	public function __construct() {
82
		@list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
83
		if ( ! is_array($this->deps) )
84
			$this->deps = array();
85
	}
86
87
	/**
88
	 * Add handle data.
89
	 *
90
	 * @access public
91
	 * @since 2.6.0
92
	 *
93
	 * @param string $name The data key to add.
94
	 * @param mixed  $data The data value to add.
95
	 * @return bool False if not scalar, true otherwise.
96
	 */
97
	public function add_data( $name, $data ) {
98
		if ( !is_scalar($name) )
99
			return false;
100
		$this->extra[$name] = $data;
101
		return true;
102
	}
103
104
}
105