@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param array|\ArrayAccess $storage |
28 | 28 | */ |
29 | - public function __construct( &$storage ) { |
|
30 | - if ( $this->isValidStorage( $storage ) ) { |
|
31 | - if ( ! isset( $storage[ $this->storage_key ] ) ) { |
|
32 | - $storage[ $this->storage_key ] = []; |
|
29 | + public function __construct(&$storage) { |
|
30 | + if ($this->isValidStorage($storage)) { |
|
31 | + if ( ! isset($storage[$this->storage_key])) { |
|
32 | + $storage[$this->storage_key] = []; |
|
33 | 33 | } |
34 | - $this->storage = &$storage[ $this->storage_key ]; |
|
34 | + $this->storage = &$storage[$this->storage_key]; |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param mixed $storage |
42 | 42 | * @return boolean |
43 | 43 | */ |
44 | - protected function isValidStorage( $storage ) { |
|
44 | + protected function isValidStorage($storage) { |
|
45 | 45 | return $storage !== null; |
46 | 46 | } |
47 | 47 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @return null |
53 | 53 | */ |
54 | 54 | protected function validateStorage() { |
55 | - if ( ! $this->isValidStorage( $this->storage ) ) { |
|
56 | - throw new Exception( 'Attempted to use Flash without an active session. Did you forget to call session_start()?' ); |
|
55 | + if ( ! $this->isValidStorage($this->storage)) { |
|
56 | + throw new Exception('Attempted to use Flash without an active session. Did you forget to call session_start()?'); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return boolean |
64 | 64 | */ |
65 | 65 | public function enabled() { |
66 | - return $this->isValidStorage( $this->storage ); |
|
66 | + return $this->isValidStorage($this->storage); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | * @param string|null $key |
73 | 73 | * @return array|\ArrayAccess |
74 | 74 | */ |
75 | - public function get( $key = null ) { |
|
75 | + public function get($key = null) { |
|
76 | 76 | $this->validateStorage(); |
77 | 77 | |
78 | - $items = $this->peek( $key ); |
|
79 | - $this->clear( $key ); |
|
78 | + $items = $this->peek($key); |
|
79 | + $this->clear($key); |
|
80 | 80 | return $items; |
81 | 81 | } |
82 | 82 | |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | * @param string|null $key |
87 | 87 | * @return array|\ArrayAccess |
88 | 88 | */ |
89 | - public function peek( $key = null ) { |
|
89 | + public function peek($key = null) { |
|
90 | 90 | $this->validateStorage(); |
91 | 91 | |
92 | - if ( $key === null ) { |
|
92 | + if ($key === null) { |
|
93 | 93 | return $this->storage; |
94 | 94 | } |
95 | 95 | |
96 | - if ( isset( $this->storage[ $key ] ) ) { |
|
97 | - return $this->storage[ $key ]; |
|
96 | + if (isset($this->storage[$key])) { |
|
97 | + return $this->storage[$key]; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return []; |
@@ -106,18 +106,18 @@ discard block |
||
106 | 106 | * @param string $key |
107 | 107 | * @param mixed $new_items |
108 | 108 | */ |
109 | - public function add( $key, $new_items ) { |
|
109 | + public function add($key, $new_items) { |
|
110 | 110 | $this->validateStorage(); |
111 | 111 | |
112 | - $new_items = is_array( $new_items ) ? $new_items : [$new_items]; |
|
112 | + $new_items = is_array($new_items) ? $new_items : [$new_items]; |
|
113 | 113 | |
114 | - $items = (array) $this->peek( $key ); |
|
115 | - $items = array_merge( $items, $new_items ); |
|
114 | + $items = (array) $this->peek($key); |
|
115 | + $items = array_merge($items, $new_items); |
|
116 | 116 | |
117 | - if ( $key === null ) { |
|
117 | + if ($key === null) { |
|
118 | 118 | $this->storage = $items; |
119 | 119 | } else { |
120 | - $this->storage[ $key ] = $items; |
|
120 | + $this->storage[$key] = $items; |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | * @param string|null $key |
128 | 128 | * @return null |
129 | 129 | */ |
130 | - public function clear( $key = null ) { |
|
130 | + public function clear($key = null) { |
|
131 | 131 | $this->validateStorage(); |
132 | 132 | |
133 | - if ( $key === null ) { |
|
133 | + if ($key === null) { |
|
134 | 134 | $this->storage = []; |
135 | 135 | } else { |
136 | - $this->storage[ $key ] = []; |
|
136 | + $this->storage[$key] = []; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | } |
140 | 140 | \ No newline at end of file |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @return boolean |
39 | 39 | */ |
40 | 40 | public static function debugging() { |
41 | - return ( defined( 'WP_DEBUG' ) && WP_DEBUG ); |
|
41 | + return (defined('WP_DEBUG') && WP_DEBUG); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * @return null |
58 | 58 | */ |
59 | 59 | public static function verifyBoot() { |
60 | - if ( ! static::isBooted() ) { |
|
61 | - throw new Exception( get_called_class() . ' must be booted first.' ); |
|
60 | + if ( ! static::isBooted()) { |
|
61 | + throw new Exception(get_called_class() . ' must be booted first.'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return Container |
69 | 69 | */ |
70 | 70 | public static function getContainer() { |
71 | - if ( static::$container === null ) { |
|
71 | + if (static::$container === null) { |
|
72 | 72 | static::$container = new Container(); |
73 | 73 | } |
74 | 74 | return static::$container; |
@@ -82,29 +82,29 @@ discard block |
||
82 | 82 | * @throws Exception |
83 | 83 | * @return null |
84 | 84 | */ |
85 | - public static function boot( $config ) { |
|
86 | - if ( static::isBooted() ) { |
|
87 | - throw new Exception( get_called_class() . ' already booted.' ); |
|
85 | + public static function boot($config) { |
|
86 | + if (static::isBooted()) { |
|
87 | + throw new Exception(get_called_class() . ' already booted.'); |
|
88 | 88 | } |
89 | 89 | static::$booted = true; |
90 | 90 | |
91 | 91 | $container = static::getContainer(); |
92 | 92 | |
93 | - $container['framework.config'] = array_merge( [ |
|
93 | + $container['framework.config'] = array_merge([ |
|
94 | 94 | 'providers' => [], |
95 | - ], $config ); |
|
95 | + ], $config); |
|
96 | 96 | |
97 | - $container['framework.service_providers'] = array_merge( [ |
|
97 | + $container['framework.service_providers'] = array_merge([ |
|
98 | 98 | RoutingServiceProvider::class, |
99 | 99 | FlashServiceProvider::class, |
100 | 100 | OldInputServiceProvider::class, |
101 | 101 | TemplatingServiceProvider::class, |
102 | - ], $container['framework.config']['providers'] ); |
|
102 | + ], $container['framework.config']['providers']); |
|
103 | 103 | |
104 | - Facade::setFacadeApplication( $container ); |
|
104 | + Facade::setFacadeApplication($container); |
|
105 | 105 | AliasLoader::getInstance()->register(); |
106 | 106 | |
107 | - static::loadServiceProviders( $container ); |
|
107 | + static::loadServiceProviders($container); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * @param Container $container |
114 | 114 | * @return null |
115 | 115 | */ |
116 | - protected static function loadServiceProviders( $container ) { |
|
117 | - $container['framework.service_providers'] = apply_filters( 'carbon_framework_service_providers', $container['framework.service_providers'] ); |
|
116 | + protected static function loadServiceProviders($container) { |
|
117 | + $container['framework.service_providers'] = apply_filters('carbon_framework_service_providers', $container['framework.service_providers']); |
|
118 | 118 | |
119 | - $service_providers = array_map( function( $service_provider ) { |
|
119 | + $service_providers = array_map(function($service_provider) { |
|
120 | 120 | return new $service_provider(); |
121 | - }, $container['framework.service_providers'] ); |
|
121 | + }, $container['framework.service_providers']); |
|
122 | 122 | |
123 | - static::registerServiceProviders( $service_providers, $container ); |
|
124 | - static::bootServiceProviders( $service_providers, $container ); |
|
123 | + static::registerServiceProviders($service_providers, $container); |
|
124 | + static::bootServiceProviders($service_providers, $container); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param Container $container |
131 | 131 | * @return null |
132 | 132 | */ |
133 | - protected static function registerServiceProviders( $service_providers, $container ) { |
|
134 | - foreach ( $service_providers as $provider ) { |
|
135 | - $provider->register( $container ); |
|
133 | + protected static function registerServiceProviders($service_providers, $container) { |
|
134 | + foreach ($service_providers as $provider) { |
|
135 | + $provider->register($container); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param Container $container |
143 | 143 | * @return null |
144 | 144 | */ |
145 | - protected static function bootServiceProviders( $service_providers, $container ) { |
|
146 | - foreach ( $service_providers as $provider ) { |
|
147 | - $provider->boot( $container ); |
|
145 | + protected static function bootServiceProviders($service_providers, $container) { |
|
146 | + foreach ($service_providers as $provider) { |
|
147 | + $provider->boot($container); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $facade_class |
156 | 156 | * @return null |
157 | 157 | */ |
158 | - public static function facade( $alias, $facade_class ) { |
|
159 | - AliasLoader::getInstance()->alias( $alias, $facade_class ); |
|
158 | + public static function facade($alias, $facade_class) { |
|
159 | + AliasLoader::getInstance()->alias($alias, $facade_class); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | * @param string $key |
166 | 166 | * @return mixed|null |
167 | 167 | */ |
168 | - public static function resolve( $key ) { |
|
168 | + public static function resolve($key) { |
|
169 | 169 | static::verifyBoot(); |
170 | 170 | |
171 | - if ( ! isset( static::getContainer()[ $key ] ) ) { |
|
171 | + if ( ! isset(static::getContainer()[$key])) { |
|
172 | 172 | return null; |
173 | 173 | } |
174 | 174 | |
175 | - return static::getContainer()[ $key ]; |
|
175 | + return static::getContainer()[$key]; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | * @param string $class |
182 | 182 | * @return object |
183 | 183 | */ |
184 | - public static function instantiate( $class ) { |
|
184 | + public static function instantiate($class) { |
|
185 | 185 | static::verifyBoot(); |
186 | 186 | |
187 | - $instance = static::resolve( $class ); |
|
187 | + $instance = static::resolve($class); |
|
188 | 188 | |
189 | - if ( $instance === null ) { |
|
189 | + if ($instance === null) { |
|
190 | 190 | $instance = new $class(); |
191 | 191 | } |
192 | 192 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param ResponseInterface $response |
200 | 200 | * @return null |
201 | 201 | */ |
202 | - public static function respond( ResponseInterface $response ) { |
|
203 | - Response::respond( $response ); |
|
202 | + public static function respond(ResponseInterface $response) { |
|
203 | + Response::respond($response); |
|
204 | 204 | } |
205 | 205 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param string|Closure $handler |
24 | 24 | */ |
25 | - public function __construct( $handler ) { |
|
26 | - $this->set( $handler ); |
|
25 | + public function __construct($handler) { |
|
26 | + $this->set($handler); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | * @param string|Closure $handler |
33 | 33 | * @return callable|array|null |
34 | 34 | */ |
35 | - protected function parse( $handler ) { |
|
36 | - if ( $handler instanceof Closure ) { |
|
35 | + protected function parse($handler) { |
|
36 | + if ($handler instanceof Closure) { |
|
37 | 37 | return $handler; |
38 | 38 | } |
39 | 39 | |
40 | - if ( is_string( $handler ) ) { |
|
41 | - $handlerPieces = preg_split( '/@|::/', $handler, 2 ); |
|
42 | - if ( count( $handlerPieces ) === 1 ) { |
|
43 | - if ( is_callable( $handlerPieces[0] ) ) { |
|
40 | + if (is_string($handler)) { |
|
41 | + $handlerPieces = preg_split('/@|::/', $handler, 2); |
|
42 | + if (count($handlerPieces) === 1) { |
|
43 | + if (is_callable($handlerPieces[0])) { |
|
44 | 44 | return $handlerPieces[0]; |
45 | 45 | } |
46 | 46 | return null; |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | * @param string|Closure $new_handler |
61 | 61 | * @return null |
62 | 62 | */ |
63 | - public function set( $new_handler ) { |
|
64 | - $handler = $this->parse( $new_handler ); |
|
63 | + public function set($new_handler) { |
|
64 | + $handler = $this->parse($new_handler); |
|
65 | 65 | |
66 | - if ( $handler === null ) { |
|
67 | - throw new Exception( 'No or invalid handler provided.' ); |
|
66 | + if ($handler === null) { |
|
67 | + throw new Exception('No or invalid handler provided.'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->handler = $handler; |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function execute() { |
79 | 79 | $arguments = func_get_args(); |
80 | - if ( is_callable( $this->handler ) ) { |
|
81 | - return call_user_func_array( $this->handler, $arguments ); |
|
80 | + if (is_callable($this->handler)) { |
|
81 | + return call_user_func_array($this->handler, $arguments); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $class = $this->handler['class']; |
85 | 85 | $method = $this->handler['method']; |
86 | 86 | |
87 | - $controller = Framework::instantiate( $class ); |
|
88 | - return call_user_func_array( [$controller, $method], $arguments ); |
|
87 | + $controller = Framework::instantiate($class); |
|
88 | + return call_user_func_array([$controller, $method], $arguments); |
|
89 | 89 | } |
90 | 90 | } |
@@ -20,22 +20,22 @@ |
||
20 | 20 | * |
21 | 21 | * @param string $post_slug |
22 | 22 | */ |
23 | - public function __construct( $post_slug ) { |
|
23 | + public function __construct($post_slug) { |
|
24 | 24 | $this->post_slug = $post_slug; |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * {@inheritDoc} |
29 | 29 | */ |
30 | - public function satisfied( Request $request ) { |
|
30 | + public function satisfied(Request $request) { |
|
31 | 31 | $post = get_post(); |
32 | - return ( $post && $this->post_slug === $post->post_name ); |
|
32 | + return ($post && $this->post_slug === $post->post_name); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * {@inheritDoc} |
37 | 37 | */ |
38 | - public function getArguments( Request $request ) { |
|
38 | + public function getArguments(Request $request) { |
|
39 | 39 | return [$this->post_slug]; |
40 | 40 | } |
41 | 41 | } |
@@ -28,24 +28,24 @@ |
||
28 | 28 | * @param string $post_template |
29 | 29 | * @param string|string[] $post_types |
30 | 30 | */ |
31 | - public function __construct( $post_template, $post_types = [] ) { |
|
31 | + public function __construct($post_template, $post_types = []) { |
|
32 | 32 | $this->post_template = $post_template; |
33 | - $this->post_types = is_array( $post_types ) ? $post_types : [$post_types]; |
|
33 | + $this->post_types = is_array($post_types) ? $post_types : [$post_types]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * {@inheritDoc} |
38 | 38 | */ |
39 | - public function satisfied( Request $request ) { |
|
40 | - $template = get_post_meta( get_the_ID(), '_wp_page_template', true ); |
|
39 | + public function satisfied(Request $request) { |
|
40 | + $template = get_post_meta(get_the_ID(), '_wp_page_template', true); |
|
41 | 41 | $template = $template ? $template : 'default'; |
42 | - return ( is_singular( $this->post_types ) && $this->post_template === $template ); |
|
42 | + return (is_singular($this->post_types) && $this->post_template === $template); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * {@inheritDoc} |
47 | 47 | */ |
48 | - public function getArguments( Request $request ) { |
|
48 | + public function getArguments(Request $request) { |
|
49 | 49 | return [$this->post_template, $this->post_types]; |
50 | 50 | } |
51 | 51 | } |
@@ -28,22 +28,22 @@ |
||
28 | 28 | * @param callable $callable |
29 | 29 | * @param mixed ...$arguments |
30 | 30 | */ |
31 | - public function __construct( $callable ) { |
|
31 | + public function __construct($callable) { |
|
32 | 32 | $this->callable = $callable; |
33 | - $this->arguments = array_slice( func_get_args(), 1 ); |
|
33 | + $this->arguments = array_slice(func_get_args(), 1); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * {@inheritDoc} |
38 | 38 | */ |
39 | - public function satisfied( Request $request ) { |
|
40 | - return call_user_func_array( $this->callable, $this->arguments ); |
|
39 | + public function satisfied(Request $request) { |
|
40 | + return call_user_func_array($this->callable, $this->arguments); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * {@inheritDoc} |
45 | 45 | */ |
46 | - public function getArguments( Request $request ) { |
|
46 | + public function getArguments(Request $request) { |
|
47 | 47 | return $this->arguments; |
48 | 48 | } |
49 | 49 | } |
@@ -20,21 +20,21 @@ |
||
20 | 20 | * |
21 | 21 | * @param string $post_id |
22 | 22 | */ |
23 | - public function __construct( $post_id ) { |
|
23 | + public function __construct($post_id) { |
|
24 | 24 | $this->post_id = $post_id; |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * {@inheritDoc} |
29 | 29 | */ |
30 | - public function satisfied( Request $request ) { |
|
30 | + public function satisfied(Request $request) { |
|
31 | 31 | return $this->post_id === get_the_ID(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * {@inheritDoc} |
36 | 36 | */ |
37 | - public function getArguments( Request $request ) { |
|
37 | + public function getArguments(Request $request) { |
|
38 | 38 | return [$this->post_id]; |
39 | 39 | } |
40 | 40 | } |
@@ -43,38 +43,38 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param string $url |
45 | 45 | */ |
46 | - public function __construct( $url ) { |
|
47 | - $url = UrlUtility::addLeadingSlash( $url ); |
|
48 | - $url = UrlUtility::addTrailingSlash( $url ); |
|
46 | + public function __construct($url) { |
|
47 | + $url = UrlUtility::addLeadingSlash($url); |
|
48 | + $url = UrlUtility::addTrailingSlash($url); |
|
49 | 49 | $this->url = $url; |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * {@inheritDoc} |
54 | 54 | */ |
55 | - public function satisfied( Request $request ) { |
|
56 | - $validation_regex = $this->getValidationRegex( $this->getUrl() ); |
|
57 | - $url = UrlUtility::getCurrentPath( $request ); |
|
58 | - return (bool) preg_match( $validation_regex, $url ); |
|
55 | + public function satisfied(Request $request) { |
|
56 | + $validation_regex = $this->getValidationRegex($this->getUrl()); |
|
57 | + $url = UrlUtility::getCurrentPath($request); |
|
58 | + return (bool) preg_match($validation_regex, $url); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * {@inheritDoc} |
63 | 63 | */ |
64 | - public function getArguments( Request $request ) { |
|
65 | - $validation_regex = $this->getValidationRegex( $this->getUrl() ); |
|
66 | - $url = UrlUtility::getCurrentPath( $request ); |
|
64 | + public function getArguments(Request $request) { |
|
65 | + $validation_regex = $this->getValidationRegex($this->getUrl()); |
|
66 | + $url = UrlUtility::getCurrentPath($request); |
|
67 | 67 | $matches = []; |
68 | - $success = preg_match( $validation_regex, $url, $matches ); |
|
68 | + $success = preg_match($validation_regex, $url, $matches); |
|
69 | 69 | |
70 | - if ( ! $success ) { |
|
70 | + if ( ! $success) { |
|
71 | 71 | return []; // this should not normally happen |
72 | 72 | } |
73 | 73 | |
74 | 74 | $arguments = []; |
75 | - $parameter_names = $this->getParameterNames( $this->getUrl() ); |
|
76 | - foreach ( $parameter_names as $parameter_name ) { |
|
77 | - $arguments[] = ! empty( $matches[ $parameter_name ] ) ? $matches[ $parameter_name ] : ''; |
|
75 | + $parameter_names = $this->getParameterNames($this->getUrl()); |
|
76 | + foreach ($parameter_names as $parameter_name) { |
|
77 | + $arguments[] = ! empty($matches[$parameter_name]) ? $matches[$parameter_name] : ''; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $arguments; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * @param Url $url |
96 | 96 | * @return Url |
97 | 97 | */ |
98 | - public function concatenate( Url $url ) { |
|
99 | - return new static( UrlUtility::removeTrailingSlash( $this->getUrl() ) . $url->getUrl() ); |
|
98 | + public function concatenate(Url $url) { |
|
99 | + return new static(UrlUtility::removeTrailingSlash($this->getUrl()) . $url->getUrl()); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string $url |
106 | 106 | * @return string[] |
107 | 107 | */ |
108 | - protected function getParameterNames( $url ) { |
|
108 | + protected function getParameterNames($url) { |
|
109 | 109 | $matches = []; |
110 | - preg_match_all( $this->url_regex, $url, $matches ); |
|
110 | + preg_match_all($this->url_regex, $url, $matches); |
|
111 | 111 | return $matches['name']; |
112 | 112 | } |
113 | 113 | |
@@ -117,29 +117,29 @@ discard block |
||
117 | 117 | * @param string $url |
118 | 118 | * @return string |
119 | 119 | */ |
120 | - protected function getValidationRegex( $url ) { |
|
120 | + protected function getValidationRegex($url) { |
|
121 | 121 | $parameters = []; |
122 | 122 | |
123 | 123 | // Replace all parameters with placeholders |
124 | - $validation_regex = preg_replace_callback( $this->url_regex, function( $matches ) use ( &$parameters ) { |
|
124 | + $validation_regex = preg_replace_callback($this->url_regex, function($matches) use (&$parameters) { |
|
125 | 125 | $name = $matches['name']; |
126 | - $optional = ! empty( $matches['optional'] ); |
|
127 | - $regex = ! empty( $matches['regex'] ) ? $matches['regex'] : $this->parameter_regex; |
|
126 | + $optional = ! empty($matches['optional']); |
|
127 | + $regex = ! empty($matches['regex']) ? $matches['regex'] : $this->parameter_regex; |
|
128 | 128 | $replacement = '(?:/(?P<' . $name . '>' . $regex . '))'; |
129 | - if ( $optional ) { |
|
129 | + if ($optional) { |
|
130 | 130 | $replacement .= '?'; |
131 | 131 | } |
132 | 132 | |
133 | - $placeholder = '___placeholder_' . sha1( count( $parameters) . '_' . $replacement . '_' . uniqid() ) . '___'; |
|
134 | - $parameters[ $placeholder ] = $replacement; |
|
133 | + $placeholder = '___placeholder_' . sha1(count($parameters) . '_' . $replacement . '_' . uniqid()) . '___'; |
|
134 | + $parameters[$placeholder] = $replacement; |
|
135 | 135 | return $placeholder; |
136 | - }, $url ); |
|
136 | + }, $url); |
|
137 | 137 | |
138 | 138 | // quote the remaining string so that it does not get evaluated as regex |
139 | - $validation_regex = preg_quote( $validation_regex, '~' ); |
|
139 | + $validation_regex = preg_quote($validation_regex, '~'); |
|
140 | 140 | |
141 | 141 | // replace the placeholders with the real parameter regexes |
142 | - $validation_regex = str_replace( array_keys( $parameters ), array_values( $parameters ), $validation_regex ); |
|
142 | + $validation_regex = str_replace(array_keys($parameters), array_values($parameters), $validation_regex); |
|
143 | 143 | |
144 | 144 | // make sure that the regex matches the entire string |
145 | 145 | $validation_regex = '~\A' . $validation_regex . '\z~'; |
@@ -20,21 +20,21 @@ |
||
20 | 20 | * |
21 | 21 | * @param string $post_type |
22 | 22 | */ |
23 | - public function __construct( $post_type ) { |
|
23 | + public function __construct($post_type) { |
|
24 | 24 | $this->post_type = $post_type; |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * {@inheritDoc} |
29 | 29 | */ |
30 | - public function satisfied( Request $request ) { |
|
30 | + public function satisfied(Request $request) { |
|
31 | 31 | return $this->post_type === get_post_type(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * {@inheritDoc} |
36 | 36 | */ |
37 | - public function getArguments( Request $request ) { |
|
37 | + public function getArguments(Request $request) { |
|
38 | 38 | return [$this->post_type]; |
39 | 39 | } |
40 | 40 | } |