Всем привет, прошу оценить с точки зрения кода, что не так?
<?php
class Router {
public static function run($options) {
$default = array (
isset ($options['default_controller_name']) ? $options['default_controller_name'] : 'home',
isset ($options['default_action_name']) ? $options['default_action_name'] : 'main'
);
$segments = isset ($_GET['r']) ? explode('/', $_GET['r']) : $default;
$controller_name = array_shift($segments);
if (empty ($controller_name))
$controller_name = $set['default_controller_name'];
$action_name = array_shift($segments);
if (empty ($action_name))
$action_name = 'main';
$_GET = array ();
$count_segments = count($segments);
if ($count_segments != 0) {
for ($i = 0; $i < $count_segments; $i++) {
$key = array_key_exists($i, $segments) ? $segments[ $i ] : null;
if (isset ($key)) {
$key = trim($key);
if (empty ($key))
$key = null;
}
if (isset ($key)) {
$_GET[ $key ] = false;
$value = array_key_exists($i, $segments) ? $segments[ ++$i ] : null;
if (isset ($value)) {
$value = trim($value);
if (empty ($value))
$value = null;
}
$_GET[ $key ] = !isset ($value) ? true : $value;
}
}
}
if (!file_exists('./application/controllers/' . $controller_name . '.php')) {
self::debug();
exit;
}
include './application/controllers/' . $controller_name . '.php';
$controller = 'Controller_' . $controller_name;
if (!class_exists($controller)) {
self::debug();
exit;
}
$controller = new $controller();
$action = 'Action_' . $action_name;
if (!method_exists($controller, $action)) {
self::debug();
exit;
}
$controller->$action();
}
private static function debug() {
}
}