Skip to content

Commit

Permalink
Fix return type
Browse files Browse the repository at this point in the history
  • Loading branch information
joanrodas committed Apr 10, 2022
1 parent bde7db3 commit 1080734
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PluboRoutes/Route/RedirectRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function isExternal()
/**
* Check if the action is a callable.
*
* @return boolean
* @return int
*/
public function getStatus()
{
Expand Down
10 changes: 2 additions & 8 deletions PluboRoutes/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function match(array $query_variables)
return new \WP_Error('missing_route_variable');
}
$route_name = $query_variables[$this->route_variable];
foreach ($this->routes as $key => $route) {
foreach ($this->routes as $route) {
if ($route->getName() === $route_name) {
return $route;
}
Expand All @@ -87,7 +87,7 @@ private function addRule(RouteInterface $route, $position = 'top')
{
$regex_path = $this->cleanPath($route->getPath());
$index_string = 'index.php?' . $this->route_variable . '=' . $route->getName();
if ($matches = $this->getMatches($regex_path)) {
if (preg_match_all('#\{(.+?)\}#', $regex_path, $matches)) {
foreach ($matches[1] as $key => $pattern) {
$pattern = explode(':', $pattern);
if (count($pattern) > 1) {
Expand All @@ -108,10 +108,4 @@ private function cleanPath($path)
{
return ltrim(trim($path), '/');
}

private function getMatches($regex_path)
{
preg_match_all('#\{(.+?)\}#', $regex_path, $matches);
return $matches;
}
}

0 comments on commit 1080734

Please sign in to comment.