1 | <?php |
||
26 | class Dispatcher extends Singleton |
||
27 | { |
||
28 | use SystemTrait; |
||
29 | /** |
||
30 | * @Injectable |
||
31 | * @var \PSFS\base\Security $security |
||
32 | */ |
||
33 | protected $security; |
||
34 | /** |
||
35 | * @Injectable |
||
36 | * @var \PSFS\base\Router $router |
||
37 | */ |
||
38 | protected $router; |
||
39 | /** |
||
40 | * @Injectable |
||
41 | * @var \PSFS\base\config\Config $config |
||
42 | */ |
||
43 | protected $config; |
||
44 | |||
45 | private $actualUri; |
||
46 | |||
47 | /** |
||
48 | * Initializer method |
||
49 | */ |
||
50 | 1 | public function init() |
|
60 | |||
61 | /** |
||
62 | * Run method |
||
63 | * @return string HTML |
||
64 | */ |
||
65 | 5 | public function run() |
|
66 | { |
||
67 | 5 | Logger::log('Begin runner'); |
|
68 | try { |
||
69 | 5 | if ($this->config->isConfigured()) { |
|
70 | //Check CORS for requests |
||
71 | 4 | RequestHelper::checkCORS(); |
|
72 | 4 | if (!Request::getInstance()->isFile()) { |
|
73 | 4 | return $this->router->execute($this->actualUri); |
|
74 | } |
||
75 | } else { |
||
76 | 1 | return ConfigController::getInstance()->config(); |
|
77 | } |
||
78 | 4 | } catch (AdminCredentialsException $a) { |
|
79 | return UserController::showAdminManager(); |
||
80 | 4 | } catch (SecurityException $s) { |
|
81 | 1 | return $this->security->notAuthorized($this->actualUri); |
|
82 | 3 | } catch (RouterException $r) { |
|
83 | 1 | return $this->router->httpNotFound($r); |
|
84 | 2 | } catch (\Exception $e) { |
|
85 | 2 | return $this->dumpException($e); |
|
86 | } |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Method that convert an exception to html |
||
91 | * |
||
92 | * @param \Exception $e |
||
93 | * |
||
94 | * @return string HTML |
||
95 | */ |
||
96 | 2 | protected function dumpException(\Exception $e) |
|
110 | |||
111 | } |
||
112 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.