@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return $this |
22 | 22 | */ |
23 | - public function define( $alias, $definition ); |
|
23 | + public function define($alias, $definition); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Defines a new singleton on the Container. |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - public function share( $alias, $definition ); |
|
36 | + public function share($alias, $definition); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Fetches the value for the provided alias. |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function fetch( $alias ); |
|
45 | + public function fetch($alias); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Checks whether the provided alias exists on the container. |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function has( $alias ); |
|
54 | + public function has($alias); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Removes the provided alias from the container. |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function remove( $alias ); |
|
63 | + public function remove($alias); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Registers a service provider with the container. |
@@ -72,5 +72,5 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param ServiceProvider $provider |
74 | 74 | */ |
75 | - public function register( ServiceProvider $provider ); |
|
75 | + public function register(ServiceProvider $provider); |
|
76 | 76 | } |
@@ -13,21 +13,21 @@ |
||
13 | 13 | * |
14 | 14 | * @param bool $debug |
15 | 15 | */ |
16 | - public function set_debug( $debug ); |
|
16 | + public function set_debug($debug); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Provides a method to register new scripts outside of the constructor. |
20 | 20 | * |
21 | 21 | * @param $script |
22 | 22 | */ |
23 | - public function register_script( $script ); |
|
23 | + public function register_script($script); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Provides a method to register new styles outside of the constructor. |
27 | 27 | * |
28 | 28 | * @param $style |
29 | 29 | */ |
30 | - public function register_style( $style ); |
|
30 | + public function register_style($style); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Enqueues the web & shared scripts on the Register. |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $vendor |
73 | 73 | */ |
74 | - public function set_vendor( $vendor ) { |
|
74 | + public function set_vendor($vendor) { |
|
75 | 75 | $this->vendor = $vendor; |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $version |
82 | 82 | */ |
83 | - public function set_version( $version ) { |
|
83 | + public function set_version($version) { |
|
84 | 84 | $this->version = $version; |
85 | 85 | } |
86 | 86 | |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | * @throws VersionNotSetException |
95 | 95 | */ |
96 | 96 | public function register() { |
97 | - if ( ! $this->vendor ) { |
|
97 | + if (!$this->vendor) { |
|
98 | 98 | throw new VendorNotSetException; |
99 | 99 | } |
100 | 100 | |
101 | - if ( ! $this->version ) { |
|
101 | + if (!$this->version) { |
|
102 | 102 | throw new VersionNotSetException; |
103 | 103 | } |
104 | 104 | |
105 | - foreach ( $this->endpoints as $endpoint ) { |
|
105 | + foreach ($this->endpoints as $endpoint) { |
|
106 | 106 | register_rest_route( |
107 | 107 | $this->get_namespace(), |
108 | 108 | $endpoint->get_route(), |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | * @param array $options |
121 | 121 | * @param callable $callback |
122 | 122 | */ |
123 | - public function group( array $options, $callback ) { |
|
123 | + public function group(array $options, $callback) { |
|
124 | 124 | $router = new static; |
125 | 125 | |
126 | - call_user_func( $callback, $router ); |
|
126 | + call_user_func($callback, $router); |
|
127 | 127 | |
128 | - foreach ( $router->get_endpoints() as $endpoint ) { |
|
129 | - $this->endpoints[] = $this->set_options( $endpoint, $options ); |
|
128 | + foreach ($router->get_endpoints() as $endpoint) { |
|
129 | + $this->endpoints[] = $this->set_options($endpoint, $options); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -145,26 +145,26 @@ discard block |
||
145 | 145 | * @throws MissingArgumentException |
146 | 146 | * @throws InvalidArgumentException |
147 | 147 | */ |
148 | - public function __call( $name, $arguments ) { |
|
149 | - if ( ! in_array( $name, array_keys( $this->methods ) ) ) { |
|
148 | + public function __call($name, $arguments) { |
|
149 | + if (!in_array($name, array_keys($this->methods))) { |
|
150 | 150 | throw new UnknownMethodException; |
151 | 151 | } |
152 | 152 | |
153 | 153 | // array_merge ensures we have 3 elements |
154 | - list( $route, $callback, $options ) = array_merge( $arguments, array( null, null, null ) ); |
|
154 | + list($route, $callback, $options) = array_merge($arguments, array(null, null, null)); |
|
155 | 155 | |
156 | - if ( ! $route || ! $callback ) { |
|
156 | + if (!$route || !$callback) { |
|
157 | 157 | throw new MissingArgumentException; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! is_callable( $callback ) ) { |
|
160 | + if (!is_callable($callback)) { |
|
161 | 161 | throw new InvalidArgumentException; |
162 | 162 | } |
163 | 163 | |
164 | - $endpoint = new Endpoint( $route, $this->methods[ $name ], $callback ); |
|
164 | + $endpoint = new Endpoint($route, $this->methods[$name], $callback); |
|
165 | 165 | |
166 | - if ( $options && is_array( $options ) ) { |
|
167 | - $endpoint = $this->set_options( $endpoint, $options ); |
|
166 | + if ($options && is_array($options)) { |
|
167 | + $endpoint = $this->set_options($endpoint, $options); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | return $this->endpoints[] = $endpoint; |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | * @return Endpoint |
182 | 182 | * @throws MalformedRouteException |
183 | 183 | */ |
184 | - protected function set_options( Endpoint $endpoint, array $options ) { |
|
185 | - if ( isset( $options['guard'] ) ) { |
|
186 | - $endpoint->set_guard( $options['guard'] ); |
|
184 | + protected function set_options(Endpoint $endpoint, array $options) { |
|
185 | + if (isset($options['guard'])) { |
|
186 | + $endpoint->set_guard($options['guard']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( isset( $options['filter'] ) ) { |
|
190 | - $endpoint->set_filter( $options['filter'] ); |
|
189 | + if (isset($options['filter'])) { |
|
190 | + $endpoint->set_filter($options['filter']); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( isset( $options['prefix'] ) ) { |
|
194 | - $endpoint->set_prefix( $options['prefix'] ); |
|
193 | + if (isset($options['prefix'])) { |
|
194 | + $endpoint->set_prefix($options['prefix']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $endpoint; |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @throws MalformedRouteException |
67 | 67 | */ |
68 | - public function __construct( $route, $method, $callback ) { |
|
69 | - if ( ! Str::starts_with( $route, '/' ) || Str::ends_with( $route, '/' ) ) { |
|
68 | + public function __construct($route, $method, $callback) { |
|
69 | + if (!Str::starts_with($route, '/') || Str::ends_with($route, '/')) { |
|
70 | 70 | throw new MalformedRouteException; |
71 | 71 | } |
72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return string |
84 | 84 | */ |
85 | 85 | public function get_route() { |
86 | - return ( $this->prefix ?: '' ) . $this->route; |
|
86 | + return ($this->prefix ?: '') . $this->route; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | 'callback' => $this->callback, |
98 | 98 | ); |
99 | 99 | |
100 | - if ( $this->guard ) { |
|
101 | - $options['permission_callback'] = array( $this->guard, 'authorized' ); |
|
100 | + if ($this->guard) { |
|
101 | + $options['permission_callback'] = array($this->guard, 'authorized'); |
|
102 | 102 | } |
103 | 103 | |
104 | - if ( $this->filter ) { |
|
104 | + if ($this->filter) { |
|
105 | 105 | $options['args'] = $this->filter->rules(); |
106 | 106 | } |
107 | 107 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return $this |
117 | 117 | */ |
118 | - public function set_guard( GuardContract $guard ) { |
|
118 | + public function set_guard(GuardContract $guard) { |
|
119 | 119 | $this->guard = $guard; |
120 | 120 | |
121 | 121 | return $this; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return $this |
130 | 130 | */ |
131 | - public function set_filter( FilterContract $filter ) { |
|
131 | + public function set_filter(FilterContract $filter) { |
|
132 | 132 | $this->filter = $filter; |
133 | 133 | |
134 | 134 | return $this; |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | * @return $this |
143 | 143 | * @throws MalformedRouteException |
144 | 144 | */ |
145 | - public function set_prefix( $prefix ) { |
|
146 | - if ( ! Str::starts_with( $prefix, '/' ) || Str::ends_with( $prefix, '/' ) ) { |
|
145 | + public function set_prefix($prefix) { |
|
146 | + if (!Str::starts_with($prefix, '/') || Str::ends_with($prefix, '/')) { |
|
147 | 147 | throw new MalformedRouteException; |
148 | 148 | } |
149 | 149 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param array $rules |
26 | 26 | */ |
27 | - public function __construct( $rules = array() ) { |
|
27 | + public function __construct($rules = array()) { |
|
28 | 28 | $this->rules = $rules; |
29 | 29 | } |
30 | 30 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | public function rules() { |
40 | 40 | $args = array(); |
41 | 41 | |
42 | - foreach ( $this->rules as $arg => $validation ) { |
|
43 | - if ( ! $validation || ! is_string( $validation ) ) { |
|
42 | + foreach ($this->rules as $arg => $validation) { |
|
43 | + if (!$validation || !is_string($validation)) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | - $args[ $arg ] = $this->parse_validation( $validation ); |
|
47 | + $args[$arg] = $this->parse_validation($validation); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return $args; |
@@ -59,43 +59,43 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @todo The next rule added needs to refactor this process. |
61 | 61 | */ |
62 | - protected function parse_validation( $validation ) { |
|
63 | - $validation = explode( '|', $validation ); |
|
62 | + protected function parse_validation($validation) { |
|
63 | + $validation = explode('|', $validation); |
|
64 | 64 | |
65 | 65 | $rules = array(); |
66 | 66 | |
67 | - foreach ( $validation as $rule ) { |
|
68 | - if ( 0 === strpos( $rule, 'default' ) ) { |
|
69 | - $rule_arr = explode( ':', $rule ); |
|
67 | + foreach ($validation as $rule) { |
|
68 | + if (0 === strpos($rule, 'default')) { |
|
69 | + $rule_arr = explode(':', $rule); |
|
70 | 70 | |
71 | - $rules['default'] = count( $rule_arr ) === 2 ? array_pop( $rule_arr ) : ''; |
|
71 | + $rules['default'] = count($rule_arr) === 2 ? array_pop($rule_arr) : ''; |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( 0 === strpos( $rule, 'oneof' ) ) { |
|
75 | - list( $rule, $values ) = explode( ':', $rule ); |
|
74 | + if (0 === strpos($rule, 'oneof')) { |
|
75 | + list($rule, $values) = explode(':', $rule); |
|
76 | 76 | |
77 | - $values = explode( ',', $values ); |
|
78 | - $callback = function ( $value ) use ( $values ) { |
|
79 | - if ( in_array( $value, $values, true ) ) { |
|
77 | + $values = explode(',', $values); |
|
78 | + $callback = function($value) use ($values) { |
|
79 | + if (in_array($value, $values, true)) { |
|
80 | 80 | return true; |
81 | 81 | } |
82 | 82 | |
83 | 83 | return false; |
84 | 84 | }; |
85 | 85 | |
86 | - $rules['validate_callback'] = isset( $rules['validate_callback'] ) ? $this->add_callback( $rules['validate_callback'], $callback ) : $callback; |
|
86 | + $rules['validate_callback'] = isset($rules['validate_callback']) ? $this->add_callback($rules['validate_callback'], $callback) : $callback; |
|
87 | 87 | } |
88 | 88 | |
89 | - switch ( $rule ) { |
|
89 | + switch ($rule) { |
|
90 | 90 | case 'required': |
91 | 91 | $rules['required'] = true; |
92 | 92 | break; |
93 | 93 | case 'integer': |
94 | - $callback = array( $this, 'validate_integer' ); |
|
95 | - $rules['validate_callback'] = isset( $rules['validate_callback'] ) ? $this->add_callback( $rules['validate_callback'], $callback ) : $callback; |
|
94 | + $callback = array($this, 'validate_integer'); |
|
95 | + $rules['validate_callback'] = isset($rules['validate_callback']) ? $this->add_callback($rules['validate_callback'], $callback) : $callback; |
|
96 | 96 | |
97 | - $callback = array( $this, 'make_integer' ); |
|
98 | - $rules['sanitize_callback'] = isset( $rules['sanitize_callback'] ) ? $this->add_callback( $rules['sanitize_callback'], $callback ) : $callback; |
|
97 | + $callback = array($this, 'make_integer'); |
|
98 | + $rules['sanitize_callback'] = isset($rules['sanitize_callback']) ? $this->add_callback($rules['sanitize_callback'], $callback) : $callback; |
|
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - public function validate_integer( $value ) { |
|
114 | - return filter_var( $value, FILTER_VALIDATE_INT ) !== false; |
|
113 | + public function validate_integer($value) { |
|
114 | + return filter_var($value, FILTER_VALIDATE_INT) !== false; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return int |
123 | 123 | */ |
124 | - public function make_integer( $value ) { |
|
124 | + public function make_integer($value) { |
|
125 | 125 | return (int) $value; |
126 | 126 | } |
127 | 127 | |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return \Closure; |
135 | 135 | */ |
136 | - private function add_callback( $previous, $next ) { |
|
137 | - return function ( $value ) use ( $previous, $next ) { |
|
138 | - if ( call_user_func( $previous, $value ) ) { |
|
139 | - return call_user_func( $next, $value ); |
|
136 | + private function add_callback($previous, $next) { |
|
137 | + return function($value) use ($previous, $next) { |
|
138 | + if (call_user_func($previous, $value)) { |
|
139 | + return call_user_func($next, $value); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return false; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param array $options |
39 | 39 | */ |
40 | - public function __construct( array $options = array() ) { |
|
41 | - $this->options = $this->set_defaults( $options ); |
|
40 | + public function __construct(array $options = array()) { |
|
41 | + $this->options = $this->set_defaults($options); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function authorized() { |
50 | 50 | // if the rule is public, always authorized |
51 | - if ( 'public' === $this->options['rule'] ) { |
|
51 | + if ('public' === $this->options['rule']) { |
|
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | |
55 | 55 | // enable passing in callback |
56 | - if ( 'callback' === $this->options['rule'] && is_callable( $this->options['callback'] ) ) { |
|
57 | - return call_user_func( $this->options['callback'] ); |
|
56 | + if ('callback' === $this->options['rule'] && is_callable($this->options['callback'])) { |
|
57 | + return call_user_func($this->options['callback']); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // map rule to method |
61 | - if ( method_exists( $this, $method = $this->options['rule'] ) ) { |
|
61 | + if (method_exists($this, $method = $this->options['rule'])) { |
|
62 | 62 | return $this->{$method}(); |
63 | 63 | } |
64 | 64 | |
65 | 65 | // disable in rule is misconfigused |
66 | 66 | // @todo set up internal translations |
67 | 67 | // @todo also, this error message kinda sucks |
68 | - return new WP_Error( '500', __( 'Guard failure', 'jaxion' ) ); |
|
68 | + return new WP_Error('500', __('Guard failure', 'jaxion')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return bool|WP_Error |
75 | 75 | */ |
76 | 76 | protected function can_edit_others_posts() { |
77 | - return current_user_can( 'edit_others_posts' ) ?: new WP_Error( 'unauthorized', __( 'Unauthorized user', 'jaxion' ), array( 'status' => 401 ) ); |
|
77 | + return current_user_can('edit_others_posts') ?: new WP_Error('unauthorized', __('Unauthorized user', 'jaxion'), array('status' => 401)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return bool|WP_Error |
84 | 84 | */ |
85 | 85 | protected function user_logged_in() { |
86 | - return is_user_logged_in() ?: new WP_Error( 'unauthorized', __( 'Unauthorized user', 'jaxion' ), array( 'status' => 401 ) ); |
|
86 | + return is_user_logged_in() ?: new WP_Error('unauthorized', __('Unauthorized user', 'jaxion'), array('status' => 401)); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - protected function set_defaults( $options ) { |
|
96 | + protected function set_defaults($options) { |
|
97 | 97 | // these are the valid options |
98 | - return wp_parse_args( $options, $this->defaults ); |
|
98 | + return wp_parse_args($options, $this->defaults); |
|
99 | 99 | } |
100 | 100 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param Container $container |
25 | 25 | */ |
26 | - public function register( Container $container ) { |
|
26 | + public function register(Container $container) { |
|
27 | 27 | $this->container = $container; |
28 | 28 | |
29 | - $this->container->define( array( 'router' => 'Intraxia\Jaxion\Http\Router' ), $router = new Router ); |
|
29 | + $this->container->define(array('router' => 'Intraxia\Jaxion\Http\Router'), $router = new Router); |
|
30 | 30 | |
31 | - $this->add_routes( $router ); |
|
31 | + $this->add_routes($router); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @codeCoverageIgnore |
43 | 43 | */ |
44 | - protected function add_routes( Router $router ) { |
|
44 | + protected function add_routes(Router $router) { |
|
45 | 45 | // no-op |
46 | 46 | } |
47 | 47 | } |
@@ -15,5 +15,5 @@ |
||
15 | 15 | * @param array $atts |
16 | 16 | * @param string $content |
17 | 17 | */ |
18 | - public function do_shortcode( array $atts, $content = '' ); |
|
18 | + public function do_shortcode(array $atts, $content = ''); |
|
19 | 19 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @param HasActions $service |
20 | 20 | */ |
21 | - public function register_actions( HasActions $service ); |
|
21 | + public function register_actions(HasActions $service); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Registers the service's filters with the loader. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param HasFilters $service |
30 | 30 | */ |
31 | - public function register_filters( HasFilters $service ); |
|
31 | + public function register_filters(HasFilters $service); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Registers the service's shortcode with the loader. |
@@ -38,5 +38,5 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param HasShortcode $service |
40 | 40 | */ |
41 | - public function register_shortcode( HasShortcode $service ); |
|
41 | + public function register_shortcode(HasShortcode $service); |
|
42 | 42 | } |