Test Failed
Push — master ( f0a15b...319182 )
by Joe
01:59
created

Loader::get_public_routes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace MyAdmin\Plugins;
4
5
/**
6
 * Class Loader
7
 *
8
 * Here are some of the regexes ive used to change code to using this class:
9
 *  ('[^']*') *=> *('[^']*'),
10
 *  $loader->add_requirement(\1, \2);
11
 *
12
 * @package MyAdmin
13
 */
14
class Loader {
0 ignored issues
show
Coding Style introduced by
The property $admin_routes is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $public_routes is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
15
	private $requirements;
16
	private $routes;
17
	private $admin_routes;
18
	private $public_routes;
19
20
	/**
21
	 * Loader constructor.
22
	 */
23
	public function __construct() {
24
		$this->requirements = [];
25
		$this->routes = [];
26
		$this->admin_routes = [];
27
		$this->public_routes = [];
28
	}
29
30
	/**
31
	 * gets the page routes
32
	 *
33
	 * @return array of routes
34
	 */
35
	public function get_routes() {
36
		return $this->routes;
37
	}
38
39
	/**
40
	 * gets the admin page routes
41
	 *
42
	 * @return array of routes
43
	 */
44
	public function get_admin_routes() {
45
		return $this->admin_routes;
46
	}
47
48
	/**
49
	 * gets the public page routes
50
	 *
51
	 * @return array of routes
52
	 */
53
	public function get_public_routes() {
54
		return $this->public_routes;
55
	}
56
57
	/**
58
	 * returns the value of a setting
59
	 *
60
	 * @param string $setting
61
	 * @return mixed the value of the setting
62
	 */
63
	public function get_setting($setting) {
64
		return constant($setting);
65
	}
66
67
	/**
68
	 * adds a requirement into the loader and registers it as a page with the router
69
	 *
70
	 * @param string $function php function name or class.class_name
71
	 * @param string $source php source file
72
	 * @param string $namespace optional php namespace
73
	 */
74
	public function add_page_requirement($function, $source, $namespace = '') {
75
		$this->routes['/'.$function] = $namespace.$function;
76
		$this->admin_routes['/'.$function] = $namespace.$function;
77
		$this->add_requirement($function, $source, $namespace);
78
	}
79
80
	/**
81
	 * adds a requirement into the loader and registers it as a page with the router
82
	 *
83
	 * @param string $function php function name or class.class_name
84
	 * @param string $source php source file
85
	 * @param string $namespace optional php namespace
86
	 */
87
	public function add_root_page_requirement($function, $source, $namespace = '') {
88
		$this->routes['/'.$function] = $namespace.$function;
89
		$this->add_requirement($function, $source, $namespace);
90
	}
91
92
	/**
93
	 * adds a requirement into the loader and registers it as a page with the router
94
	 *
95
	 * @param string $function php function name or class.class_name
0 ignored issues
show
Bug introduced by
There is no parameter named $function. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
96
	 * @param string $path source file path
0 ignored issues
show
Bug introduced by
There is no parameter named $path. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
97
	 */
98
	public function add_public_path($page, $source) {
99
		$this->public_routes['/'.$page] = $source;
100
	}
101
102
	/**
103
	 * adds a requirement into the loader and registers it as a page with the router
104
	 *
105
	 * @param string $function php function name or class.class_name
106
	 * @param string $source php source file
107
	 * @param string $namespace optional php namespace
108
	 */
109
	public function add_ajax_page_requirement($function, $source, $namespace = '') {
110
		$this->routes['/ajax/'.$function] = $namespace.$function;
111
		$this->add_requirement($function, $source, $namespace);
112
	}
113
114
	/**
115
	 * adds a requirement into the loader and registers it as a page with the router
116
	 *
117
	 * @param string $function php function name or class.class_name
118
	 * @param string $source php source file
119
	 * @param string $namespace optional php namespace
120
	 */
121
	public function add_admin_page_requirement($function, $source, $namespace = '') {
122
		$this->admin_routes['/'.$function] = $namespace.$function;
123
		$this->add_requirement($function, $source, $namespace);
124
	}
125
126
	/**
127
	 * adds a requirement into the loader
128
	 *
129
	 * @param string $function php function name or class.class_name
130
	 * @param string $source php source file
131
	 * @param string $namespace optional php namespace
132
	 */
133
	public function add_requirement($function, $source, $namespace = '') {
134
		$this->requirements[$function] = $namespace.$source;
135
	}
136
137
	/**
138
	 * gets an array of requirements for loading
139
	 *
140
	 * @return array the array of requirements
141
	 */
142
	public function get_requirements() {
143
		return $this->requirements;
144
	}
145
}
146
147