Fix some style issues
Some checks failed
timw4mail/HummingBirdAnimeClient/pipeline/head There was a failure building this commit

This commit is contained in:
Timothy Warren 2020-03-16 15:06:55 -04:00
parent 39f672b35f
commit 9259c85586
4 changed files with 36 additions and 36 deletions

View File

@ -129,14 +129,7 @@ final class Dispatcher extends RoutingBase {
} }
} }
if ($route) if ( ! $route)
{
$parsed = $this->processRoute(new Friend($route));
$controllerName = $parsed['controller_name'];
$actionMethod = $parsed['action_method'];
$params = $parsed['params'];
}
else
{ {
// If not route was matched, return an appropriate http // If not route was matched, return an appropriate http
// error message // error message
@ -144,8 +137,15 @@ final class Dispatcher extends RoutingBase {
$controllerName = DEFAULT_CONTROLLER; $controllerName = DEFAULT_CONTROLLER;
$actionMethod = $errorRoute['action_method']; $actionMethod = $errorRoute['action_method'];
$params = $errorRoute['params']; $params = $errorRoute['params'];
$this->call($controllerName, $actionMethod, $params);
return;
} }
$parsed = $this->processRoute(new Friend($route));
$controllerName = $parsed['controller_name'];
$actionMethod = $parsed['action_method'];
$params = $parsed['params'];
$this->call($controllerName, $actionMethod, $params); $this->call($controllerName, $actionMethod, $params);
} }
@ -159,14 +159,15 @@ final class Dispatcher extends RoutingBase {
*/ */
protected function processRoute($route): array protected function processRoute($route): array
{ {
if ( ! array_key_exists('controller', $route->attributes))
{
throw new LogicException('Missing controller');
}
if (array_key_exists('controller', $route->attributes)) if (array_key_exists('controller', $route->attributes))
{ {
$controllerName = $route->attributes['controller']; $controllerName = $route->attributes['controller'];
} }
else
{
throw new LogicException('Missing controller');
}
// Get the full namespace for a controller if a short name is given // Get the full namespace for a controller if a short name is given
if (strpos($controllerName, '\\') === FALSE) if (strpos($controllerName, '\\') === FALSE)
@ -392,16 +393,15 @@ final class Dispatcher extends RoutingBase {
if ( ! array_key_exists('tokens', $route)) if ( ! array_key_exists('tokens', $route))
{ {
$routes[] = $this->router->$add($name, $path)->defaults($route); $routes[] = $this->router->$add($name, $path)->defaults($route);
continue;
} }
else
{
$tokens = $route['tokens'];
unset($route['tokens']);
$routes[] = $this->router->$add($name, $path) $tokens = $route['tokens'];
->defaults($route) unset($route['tokens']);
->tokens($tokens);
} $routes[] = $this->router->$add($name, $path)
->defaults($route)
->tokens($tokens);
} }
return $routes; return $routes;

View File

@ -72,10 +72,10 @@ final class MenuGenerator extends UrlGenerator {
foreach ($menus as $name => $menu) foreach ($menus as $name => $menu)
{ {
$parsed[$name] = []; $parsed[$name] = [];
foreach ($menu['items'] as $path_name => $partial_path) foreach ($menu['items'] as $pathName => $partialPath)
{ {
$title = (string)$this->string($path_name)->humanize()->titleize(); $title = (string)$this->string($pathName)->humanize()->titleize();
$parsed[$name][$title] = (string)$this->string($menu['route_prefix'])->append($partial_path); $parsed[$name][$title] = (string)$this->string($menu['route_prefix'])->append($partialPath);
} }
} }

View File

@ -76,20 +76,20 @@ class UrlGenerator extends RoutingBase {
// Remove any optional parameters from the route // Remove any optional parameters from the route
// and replace them with existing route parameters, if they exist // and replace them with existing route parameters, if they exist
$path_segments = explode('/', $path); $pathSegments = explode('/', $path);
$segment_count = count($path_segments); $segmentCount = count($pathSegments);
$segments = $this->segments(); $segments = $this->segments();
for ($i = 0; $i < $segment_count; $i++) for ($i = 0; $i < $segmentCount; $i++)
{ {
if ( ! array_key_exists($i + 1, $segments)) if ( ! array_key_exists($i + 1, $segments))
{ {
$segments[$i + 1] = ''; $segments[$i + 1] = '';
} }
$path_segments[$i] = preg_replace('`{.*?}`', $segments[$i + 1], $path_segments[$i]); $pathSegments[$i] = preg_replace('`{.*?}`', $segments[$i + 1], $pathSegments[$i]);
} }
$path = implode('/', $path_segments); $path = implode('/', $pathSegments);
$scheme = $this->config->get('secure_urls') !== FALSE ? 'https:' : 'http:'; $scheme = $this->config->get('secure_urls') !== FALSE ? 'https:' : 'http:';

View File

@ -57,25 +57,25 @@ class Util {
/** /**
* HTML selection helper function * HTML selection helper function
* *
* @param string $a - First item to compare * @param string $left - First item to compare
* @param string $b - Second item to compare * @param string $right - Second item to compare
* @return string * @return string
*/ */
public static function isSelected(string $a, string $b): string public static function isSelected(string $left, string $right): string
{ {
return ($a === $b) ? 'selected' : ''; return ($left === $right) ? 'selected' : '';
} }
/** /**
* Inverse of selected helper function * Inverse of selected helper function
* *
* @param string $a - First item to compare * @param string $left - First item to compare
* @param string $b - Second item to compare * @param string $right - Second item to compare
* @return string * @return string
*/ */
public static function isNotSelected(string $a, string $b): string public static function isNotSelected(string $left, string $right): string
{ {
return ($a !== $b) ? 'selected' : ''; return ($left !== $right) ? 'selected' : '';
} }
/** /**