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

View File

@ -72,10 +72,10 @@ final class MenuGenerator extends UrlGenerator {
foreach ($menus as $name => $menu)
{
$parsed[$name] = [];
foreach ($menu['items'] as $path_name => $partial_path)
foreach ($menu['items'] as $pathName => $partialPath)
{
$title = (string)$this->string($path_name)->humanize()->titleize();
$parsed[$name][$title] = (string)$this->string($menu['route_prefix'])->append($partial_path);
$title = (string)$this->string($pathName)->humanize()->titleize();
$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
// and replace them with existing route parameters, if they exist
$path_segments = explode('/', $path);
$segment_count = count($path_segments);
$pathSegments = explode('/', $path);
$segmentCount = count($pathSegments);
$segments = $this->segments();
for ($i = 0; $i < $segment_count; $i++)
for ($i = 0; $i < $segmentCount; $i++)
{
if ( ! array_key_exists($i + 1, $segments))
{
$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:';

View File

@ -57,25 +57,25 @@ class Util {
/**
* HTML selection helper function
*
* @param string $a - First item to compare
* @param string $b - Second item to compare
* @param string $left - First item to compare
* @param string $right - Second item to compare
* @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
*
* @param string $a - First item to compare
* @param string $b - Second item to compare
* @param string $left - First item to compare
* @param string $right - Second item to compare
* @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' : '';
}
/**