@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | public function load($routes) { |
| 141 | 141 | |
| 142 | - if ( !empty($routes) ) { |
|
| 142 | + if (!empty($routes)) { |
|
| 143 | 143 | |
| 144 | - foreach( $routes as $name => $route ) { |
|
| 144 | + foreach ($routes as $name => $route) { |
|
| 145 | 145 | |
| 146 | 146 | $this->add($route['route'], $route['type'], $route['class'], $route['parameters']); |
| 147 | 147 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | private function readCache() { |
| 159 | 159 | |
| 160 | - if ( $this->configuration()->get('routing-table-cache') !== true ) return; |
|
| 160 | + if ($this->configuration()->get('routing-table-cache') !== true) return; |
|
| 161 | 161 | |
| 162 | 162 | $routes = $this->cache->setNamespace('dispatcher-internals')->get("dispatcher-routes"); |
| 163 | 163 | |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | private function dumpCache() { |
| 179 | 179 | |
| 180 | - if ( $this->configuration()->get('routing-table-cache') !== true ) return; |
|
| 180 | + if ($this->configuration()->get('routing-table-cache') !== true) return; |
|
| 181 | 181 | |
| 182 | 182 | $ttl = $this->configuration()->get('routing-table-ttl'); |
| 183 | 183 | |
| 184 | 184 | $routes = array(); |
| 185 | 185 | |
| 186 | - foreach($this->routes as $name => $route) { |
|
| 186 | + foreach ($this->routes as $name => $route) { |
|
| 187 | 187 | |
| 188 | 188 | $routes[$name] = $route->getData(); |
| 189 | 189 | |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | ->setClassName($class) // Class to be invoked |
| 205 | 205 | ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...) |
| 206 | 206 | |
| 207 | - $this->logger->debug("ROUTE: " . implode("/", $folders)); |
|
| 207 | + $this->logger->debug("ROUTE: ".implode("/", $folders)); |
|
| 208 | 208 | |
| 209 | 209 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
| 210 | 210 | |
| 211 | 211 | // This method generate a global regular expression which will be able to match all the URI supported by the route |
| 212 | 212 | $regex = $this->parser->read($folders, $route); |
| 213 | 213 | |
| 214 | - $this->logger->debug("ROUTE: " . $regex); |
|
| 214 | + $this->logger->debug("ROUTE: ".$regex); |
|
| 215 | 215 | |
| 216 | 216 | //$this->logger->debug("PARAMETERS: " . var_export($value, true)); |
| 217 | 217 | |
@@ -84,10 +84,11 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $regex = $this->regex($route); |
| 86 | 86 | |
| 87 | - if (isset($this->routes[$regex])) |
|
| 88 | - return $this->routes[$regex]; |
|
| 89 | - else |
|
| 90 | - return null; |
|
| 87 | + if (isset($this->routes[$regex])) { |
|
| 88 | + return $this->routes[$regex]; |
|
| 89 | + } else { |
|
| 90 | + return null; |
|
| 91 | + } |
|
| 91 | 92 | |
| 92 | 93 | } |
| 93 | 94 | |
@@ -157,11 +158,15 @@ discard block |
||
| 157 | 158 | |
| 158 | 159 | private function readCache() { |
| 159 | 160 | |
| 160 | - if ( $this->configuration()->get('routing-table-cache') !== true ) return; |
|
| 161 | + if ( $this->configuration()->get('routing-table-cache') !== true ) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 161 | 164 | |
| 162 | 165 | $routes = $this->cache->setNamespace('dispatcher-internals')->get("dispatcher-routes"); |
| 163 | 166 | |
| 164 | - if (is_null($routes)) return; |
|
| 167 | + if (is_null($routes)) { |
|
| 168 | + return; |
|
| 169 | + } |
|
| 165 | 170 | |
| 166 | 171 | foreach ($routes as $name => $data) { |
| 167 | 172 | |
@@ -177,7 +182,9 @@ discard block |
||
| 177 | 182 | |
| 178 | 183 | private function dumpCache() { |
| 179 | 184 | |
| 180 | - if ( $this->configuration()->get('routing-table-cache') !== true ) return; |
|
| 185 | + if ( $this->configuration()->get('routing-table-cache') !== true ) { |
|
| 186 | + return; |
|
| 187 | + } |
|
| 181 | 188 | |
| 182 | 189 | $ttl = $this->configuration()->get('routing-table-ttl'); |
| 183 | 190 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | private $response; |
| 74 | 74 | |
| 75 | - public function __construct(Configuration $configuration,LoggerInterface $logger, Response $response) { |
|
| 75 | + public function __construct(Configuration $configuration, LoggerInterface $logger, Response $response) { |
|
| 76 | 76 | |
| 77 | 77 | parent::__construct($configuration, $logger); |
| 78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $output_class_name = "\\Comodojo\\Dispatcher\\Output\\HttpStatus\\Status".$status; |
| 88 | 88 | |
| 89 | - if ( class_exists($output_class_name) ) { |
|
| 89 | + if (class_exists($output_class_name)) { |
|
| 90 | 90 | |
| 91 | 91 | $output = new $output_class_name($this->response); |
| 92 | 92 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | $type = $this->response->content()->type(); |
| 124 | 124 | $charset = $this->response->content()->charset(); |
| 125 | 125 | |
| 126 | - if ( is_null($charset) ) { |
|
| 127 | - $this->response->headers()->set("Content-type",strtolower($type)); |
|
| 126 | + if (is_null($charset)) { |
|
| 127 | + $this->response->headers()->set("Content-type", strtolower($type)); |
|
| 128 | 128 | } else { |
| 129 | - $this->response->headers()->set("Content-type",strtolower($type)."; charset=".$charset); |
|
| 129 | + $this->response->headers()->set("Content-type", strtolower($type)."; charset=".$charset); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | } |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $supported_methods = $this->configuration()->get('supported-http-methods'); |
| 98 | 98 | |
| 99 | - if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT'); |
|
| 99 | + if (is_null($supported_methods)) $supported_methods = array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT'); |
|
| 100 | 100 | |
| 101 | - if ( method_exists($this, 'any') ) { |
|
| 101 | + if (method_exists($this, 'any')) { |
|
| 102 | 102 | |
| 103 | 103 | return $supported_methods; |
| 104 | 104 | |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | $implemented_methods = array(); |
| 108 | 108 | |
| 109 | - foreach ( $supported_methods as $method ) { |
|
| 109 | + foreach ($supported_methods as $method) { |
|
| 110 | 110 | |
| 111 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
| 111 | + if (method_exists($this, strtolower($method))) array_push($implemented_methods, $method); |
|
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function getMethod($method) { |
| 124 | 124 | |
| 125 | - if ( method_exists($this, strtolower($method)) ) { |
|
| 125 | + if (method_exists($this, strtolower($method))) { |
|
| 126 | 126 | |
| 127 | 127 | return strtolower($method); |
| 128 | 128 | |
| 129 | - } else if ( method_exists($this, strtolower('any')) ) { |
|
| 129 | + } else if (method_exists($this, strtolower('any'))) { |
|
| 130 | 130 | |
| 131 | 131 | return 'any'; |
| 132 | 132 | |
@@ -96,7 +96,9 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $supported_methods = $this->configuration()->get('supported-http-methods'); |
| 98 | 98 | |
| 99 | - if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT'); |
|
| 99 | + if ( is_null($supported_methods) ) { |
|
| 100 | + $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT'); |
|
| 101 | + } |
|
| 100 | 102 | |
| 101 | 103 | if ( method_exists($this, 'any') ) { |
| 102 | 104 | |
@@ -108,7 +110,9 @@ discard block |
||
| 108 | 110 | |
| 109 | 111 | foreach ( $supported_methods as $method ) { |
| 110 | 112 | |
| 111 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
| 113 | + if ( method_exists($this, strtolower($method)) ) { |
|
| 114 | + array_push($implemented_methods,$method); |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | } |
| 114 | 118 | |
@@ -65,7 +65,9 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $handler = $this->getHandler($provider, $parameters); |
| 67 | 67 | |
| 68 | - if ( $handler instanceof HandlerInterface ) $logger->pushHandler($handler); |
|
| 68 | + if ( $handler instanceof HandlerInterface ) { |
|
| 69 | + $logger->pushHandler($handler); |
|
| 70 | + } |
|
| 69 | 71 | |
| 70 | 72 | } |
| 71 | 73 | |
@@ -112,7 +114,9 @@ discard block |
||
| 112 | 114 | |
| 113 | 115 | case 'SyslogHandler': |
| 114 | 116 | |
| 115 | - if ( empty($parameters['ident']) ) return null; |
|
| 117 | + if ( empty($parameters['ident']) ) { |
|
| 118 | + return null; |
|
| 119 | + } |
|
| 116 | 120 | |
| 117 | 121 | $facility = empty($parameters['facility']) ? LOG_USER : $parameters['facility']; |
| 118 | 122 | |
@@ -211,7 +215,9 @@ discard block |
||
| 211 | 215 | |
| 212 | 216 | protected static function getFilePermission($filepermission = null) {
|
| 213 | 217 | |
| 214 | - if ( is_null($filepermission) ) return null; |
|
| 218 | + if ( is_null($filepermission) ) { |
|
| 219 | + return null; |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | return filter_var($bubble, FILTER_VALIDATE_INT, array( |
| 217 | 223 | 'options' => array( |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | if ( |
| 49 | 49 | empty($log) || |
| 50 | - ( isset($log['enabled']) && $log['enabled'] === false ) || |
|
| 50 | + (isset($log['enabled']) && $log['enabled'] === false) || |
|
| 51 | 51 | empty($log['providers']) |
| 52 | 52 | ) {
|
| 53 | 53 | |
| 54 | 54 | $logger = new Logger('dispatcher');
|
| 55 | 55 | |
| 56 | - $logger->pushHandler( new NullHandler( self::getLevel() ) ); |
|
| 56 | + $logger->pushHandler(new NullHandler(self::getLevel())); |
|
| 57 | 57 | |
| 58 | 58 | } else {
|
| 59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $handler = $this->getHandler($provider, $parameters); |
| 67 | 67 | |
| 68 | - if ( $handler instanceof HandlerInterface ) $logger->pushHandler($handler); |
|
| 68 | + if ($handler instanceof HandlerInterface) $logger->pushHandler($handler); |
|
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
@@ -92,19 +92,19 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | protected function getHandler($provider, $parameters) {
|
| 94 | 94 | |
| 95 | - switch ( $parameters['type'] ) {
|
|
| 95 | + switch ($parameters['type']) {
|
|
| 96 | 96 | |
| 97 | 97 | case 'StreamHandler': |
| 98 | 98 | |
| 99 | 99 | $stream = $this->configuration->get('base-path').'/'.(empty($parameters['stream']) ? 'dispatcher.log' : $parameters['stream']);
|
| 100 | 100 | |
| 101 | - $level = self::getLevel( empty($parameters['level']) ? null : $parameters['level'] ); |
|
| 101 | + $level = self::getLevel(empty($parameters['level']) ? null : $parameters['level']); |
|
| 102 | 102 | |
| 103 | - $bubble = self::getBubble( empty($parameters['bubble']) ? true : $parameters['bubble'] ); |
|
| 103 | + $bubble = self::getBubble(empty($parameters['bubble']) ? true : $parameters['bubble']); |
|
| 104 | 104 | |
| 105 | - $filePermission = self::getFilePermission( empty($parameters['filePermission']) ? null : $parameters['filePermission'] ); |
|
| 105 | + $filePermission = self::getFilePermission(empty($parameters['filePermission']) ? null : $parameters['filePermission']); |
|
| 106 | 106 | |
| 107 | - $useLocking = self::getLocking( empty($parameters['useLocking']) ? false : $parameters['useLocking'] ); |
|
| 107 | + $useLocking = self::getLocking(empty($parameters['useLocking']) ? false : $parameters['useLocking']); |
|
| 108 | 108 | |
| 109 | 109 | $handler = new StreamHandler($stream, $level, $bubble, $filePermission, $useLocking); |
| 110 | 110 | |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | case 'SyslogHandler': |
| 114 | 114 | |
| 115 | - if ( empty($parameters['ident']) ) return null; |
|
| 115 | + if (empty($parameters['ident'])) return null; |
|
| 116 | 116 | |
| 117 | 117 | $facility = empty($parameters['facility']) ? LOG_USER : $parameters['facility']; |
| 118 | 118 | |
| 119 | - $level = self::getLevel( empty($parameters['level']) ? null : $parameters['level'] ); |
|
| 119 | + $level = self::getLevel(empty($parameters['level']) ? null : $parameters['level']); |
|
| 120 | 120 | |
| 121 | - $bubble = self::getBubble( empty($parameters['bubble']) ? true : $parameters['bubble'] ); |
|
| 121 | + $bubble = self::getBubble(empty($parameters['bubble']) ? true : $parameters['bubble']); |
|
| 122 | 122 | |
| 123 | 123 | $logopts = empty($parameters['logopts']) ? LOG_PID : $parameters['logopts']; |
| 124 | 124 | |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $messageType = empty($parameters['messageType']) ? ErrorLogHandler::OPERATING_SYSTEM : $parameters['messageType']; |
| 132 | 132 | |
| 133 | - $level = self::getLevel( empty($parameters['level']) ? null : $parameters['level'] ); |
|
| 133 | + $level = self::getLevel(empty($parameters['level']) ? null : $parameters['level']); |
|
| 134 | 134 | |
| 135 | - $bubble = self::getBubble( empty($parameters['bubble']) ? true : $parameters['bubble'] ); |
|
| 135 | + $bubble = self::getBubble(empty($parameters['bubble']) ? true : $parameters['bubble']); |
|
| 136 | 136 | |
| 137 | - $expandNewlines = self::getExpandNewlines( empty($parameters['expandNewlines']) ? false : $parameters['expandNewlines'] ); |
|
| 137 | + $expandNewlines = self::getExpandNewlines(empty($parameters['expandNewlines']) ? false : $parameters['expandNewlines']); |
|
| 138 | 138 | |
| 139 | 139 | $handler = new ErrorLogHandler($messageType, $level, $bubble, $expandNewlines); |
| 140 | 140 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected static function getLevel($level = null) {
|
| 160 | 160 | |
| 161 | - switch ( strtoupper($level) ) {
|
|
| 161 | + switch (strtoupper($level)) {
|
|
| 162 | 162 | |
| 163 | 163 | case 'INFO': |
| 164 | 164 | $logger_level = Logger::INFO; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | protected static function getFilePermission($filepermission = null) {
|
| 213 | 213 | |
| 214 | - if ( is_null($filepermission) ) return null; |
|
| 214 | + if (is_null($filepermission)) return null; |
|
| 215 | 215 | |
| 216 | 216 | return filter_var($filepermission, FILTER_VALIDATE_INT, array( |
| 217 | 217 | 'options' => array( |
@@ -48,11 +48,11 @@ |
||
| 48 | 48 | |
| 49 | 49 | private static function urlGetAbsolute() { |
| 50 | 50 | |
| 51 | - $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://'; |
|
| 51 | + $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'; |
|
| 52 | 52 | |
| 53 | 53 | $uri = self::uriGetAbsolute(); |
| 54 | 54 | |
| 55 | - return ( $http . $_SERVER['HTTP_HOST'] . $uri . "/" ); |
|
| 55 | + return ($http.$_SERVER['HTTP_HOST'].$uri."/"); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |