@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'encoding' => 'UTF-8', |
| 31 | 31 | 'disabled-status' => 503, |
| 32 | 32 | 'disabled-message' => 'Dispatcher offline', |
| 33 | - 'supported-methods' => array('GET','PUT','POST','DELETE','OPTIONS','HEAD') |
|
| 33 | + 'supported-methods' => array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD') |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | 36 | public static function get() { |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | private static function urlGetAbsolute() { |
| 49 | 49 | |
| 50 | - $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://'; |
|
| 50 | + $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'; |
|
| 51 | 51 | |
| 52 | 52 | $uri = preg_replace("/\/index.php(.*?)$/i", "", $_SERVER['PHP_SELF']); |
| 53 | 53 | |
| 54 | - return ( $http . $_SERVER['HTTP_HOST'] . $uri . "/" ); |
|
| 54 | + return ($http.$_SERVER['HTTP_HOST'].$uri."/"); |
|
| 55 | 55 | |
| 56 | 56 | } |
| 57 | 57 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $this->extra = new Extra($this->logger); |
| 77 | 77 | |
| 78 | - $this->configuration = new Configuration( DefaultConfiguration::get() ); |
|
| 78 | + $this->configuration = new Configuration(DefaultConfiguration::get()); |
|
| 79 | 79 | |
| 80 | 80 | $this->configuration->merge($configuration); |
| 81 | 81 | |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | public function dispatch() { |
| 139 | 139 | |
| 140 | - $this->events->emit( new DispatcherEvent($this) ); |
|
| 140 | + $this->events->emit(new DispatcherEvent($this)); |
|
| 141 | 141 | |
| 142 | - if ( $this->configuration()->get('enabled') === false ) { |
|
| 142 | + if ($this->configuration()->get('enabled') === false) { |
|
| 143 | 143 | |
| 144 | 144 | $status = $this->configuration()->get('disabled-status'); |
| 145 | 145 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request') ); |
|
| 156 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request')); |
|
| 157 | 157 | |
| 158 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method()->get()) ); |
|
| 158 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method()->get())); |
|
| 159 | 159 | |
| 160 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') ); |
|
| 160 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.#')); |
|
| 161 | 161 | |
| 162 | 162 | try { |
| 163 | 163 | |
@@ -165,21 +165,21 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | } catch (DispatcherException $de) { |
| 167 | 167 | |
| 168 | - $this->response()->status()->set( $de->getStatus() ); |
|
| 168 | + $this->response()->status()->set($de->getStatus()); |
|
| 169 | 169 | |
| 170 | - $this->response()->content()->set( $de->getMessage() ); |
|
| 170 | + $this->response()->content()->set($de->getMessage()); |
|
| 171 | 171 | |
| 172 | 172 | return $this->shutdown(); |
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route') ); |
|
| 176 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route')); |
|
| 177 | 177 | |
| 178 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getType()) ); |
|
| 178 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getType())); |
|
| 179 | 179 | |
| 180 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getService()) ); |
|
| 180 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getService())); |
|
| 181 | 181 | |
| 182 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') ); |
|
| 182 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.#')); |
|
| 183 | 183 | |
| 184 | 184 | // translate route to service |
| 185 | 185 | |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | } catch (DispatcherException $de) { |
| 191 | 191 | |
| 192 | - $this->response()->status()->set( $de->getStatus() ); |
|
| 192 | + $this->response()->status()->set($de->getStatus()); |
|
| 193 | 193 | |
| 194 | - $this->response()->content()->set( $de->getMessage() ); |
|
| 194 | + $this->response()->content()->set($de->getMessage()); |
|
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | private function shutdown() { |
| 216 | 216 | |
| 217 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response') ); |
|
| 217 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response')); |
|
| 218 | 218 | |
| 219 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status()->get()) ); |
|
| 219 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status()->get())); |
|
| 220 | 220 | |
| 221 | - $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') ); |
|
| 221 | + $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.#')); |
|
| 222 | 222 | |
| 223 | 223 | $return = Processor::parse($this->configuration, $this->logger, $this->response); |
| 224 | 224 | |
@@ -45,13 +45,13 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | if ( |
| 47 | 47 | empty($log) || |
| 48 | - ( isset($log['enabled']) && $log['enabled'] === false ) || |
|
| 48 | + (isset($log['enabled']) && $log['enabled'] === false) || |
|
| 49 | 49 | empty($log['providers']) |
| 50 | 50 | ) {
|
| 51 | 51 | |
| 52 | 52 | $logger = new Logger('dispatcher');
|
| 53 | 53 | |
| 54 | - $logger->pushHandler( new NullHandler( self::getLevel() ) ); |
|
| 54 | + $logger->pushHandler(new NullHandler(self::getLevel())); |
|
| 55 | 55 | |
| 56 | 56 | } else {
|
| 57 | 57 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $handler = $this->getHandler($provider, $parameters); |
| 65 | 65 | |
| 66 | - if ( $handler instanceof HandlerInterface ) $logger->pushHandler($handler); |
|
| 66 | + if ($handler instanceof HandlerInterface) $logger->pushHandler($handler); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | protected function getHandler($provider, $parameters) {
|
| 92 | 92 | |
| 93 | - switch ( strtolower($parameters['type']) ) {
|
|
| 93 | + switch (strtolower($parameters['type'])) {
|
|
| 94 | 94 | |
| 95 | 95 | case 'streamhandler': |
| 96 | 96 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $file = $this->configuration->get('base-path').'/'.$target;
|
| 100 | 100 | |
| 101 | - $level = self::getLevel( empty($parameters['level']) ? 'info' : $parameters['level'] ); |
|
| 101 | + $level = self::getLevel(empty($parameters['level']) ? 'info' : $parameters['level']); |
|
| 102 | 102 | |
| 103 | 103 | $handler = new StreamHandler($file, $level); |
| 104 | 104 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | protected static function getLevel($level = null) {
|
| 124 | 124 | |
| 125 | - switch ( strtoupper($level) ) {
|
|
| 125 | + switch (strtoupper($level)) {
|
|
| 126 | 126 | |
| 127 | 127 | case 'INFO': |
| 128 | 128 | $logger_level = Logger::INFO; |
@@ -63,7 +63,9 @@ |
||
| 63 | 63 | |
| 64 | 64 | $handler = $this->getHandler($provider, $parameters); |
| 65 | 65 | |
| 66 | - if ( $handler instanceof HandlerInterface ) $logger->pushHandler($handler); |
|
| 66 | + if ( $handler instanceof HandlerInterface ) { |
|
| 67 | + $logger->pushHandler($handler); |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | } |
| 69 | 71 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function subscribe($event, $class, $method = null, $priority = 0) { |
| 32 | 32 | |
| 33 | - $callable = ( is_null($method) ) ? $class : array($class, $method); |
|
| 33 | + $callable = (is_null($method)) ? $class : array($class, $method); |
|
| 34 | 34 | |
| 35 | 35 | return $this->addListener($event, $callable, $priority); |
| 36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function subscribeOnce($event, $class, $method = null, $priority = 0) { |
| 40 | 40 | |
| 41 | - $callable = ( is_null($method) ) ? $class : array($class, $method); |
|
| 41 | + $callable = (is_null($method)) ? $class : array($class, $method); |
|
| 42 | 42 | |
| 43 | 43 | return $this->addOneTimeListener($event, $callable, $priority); |
| 44 | 44 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $events = Yaml::parse($yaml); |
| 50 | 50 | |
| 51 | - if ( !empty($events) ) { |
|
| 51 | + if (!empty($events)) { |
|
| 52 | 52 | |
| 53 | - foreach( $events as $name => $event ) { |
|
| 53 | + foreach ($events as $name => $event) { |
|
| 54 | 54 | |
| 55 | - $callable = ( is_null($event['method']) ) ? $event["class"] : array($event["class"], $event["method"]); |
|
| 55 | + $callable = (is_null($event['method'])) ? $event["class"] : array($event["class"], $event["method"]); |
|
| 56 | 56 | |
| 57 | 57 | $this->addListener($event["event"], $callable, $event["priority"]); |
| 58 | 58 | |
@@ -46,25 +46,25 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $cache = $this->configuration->get('cache');
|
| 48 | 48 | |
| 49 | - if ( empty($cache) ) {
|
|
| 49 | + if (empty($cache)) {
|
|
| 50 | 50 | |
| 51 | 51 | $manager = new CacheManager(self::getAlgorithm(), $this->logger); |
| 52 | 52 | |
| 53 | 53 | } else {
|
| 54 | 54 | |
| 55 | - $enabled = ( empty($cache['enabled']) || $cache['enabled'] === true ) ? true : false; |
|
| 55 | + $enabled = (empty($cache['enabled']) || $cache['enabled'] === true) ? true : false; |
|
| 56 | 56 | |
| 57 | - $algorithm = self::getAlgorithm( empty($cache['algorithm']) ? null : $cache['algorithm']); |
|
| 57 | + $algorithm = self::getAlgorithm(empty($cache['algorithm']) ? null : $cache['algorithm']); |
|
| 58 | 58 | |
| 59 | 59 | $manager = new CacheManager($algorithm, $this->logger); |
| 60 | 60 | |
| 61 | - if ( $enabled && !empty($cache['providers']) ) {
|
|
| 61 | + if ($enabled && !empty($cache['providers'])) {
|
|
| 62 | 62 | |
| 63 | 63 | foreach ($cache['providers'] as $provider => $parameters) {
|
| 64 | 64 | |
| 65 | 65 | $handler = $this->getHandler($provider, $parameters); |
| 66 | 66 | |
| 67 | - if ( $handler instanceof CacheInterface ) $manager->addProvider($handler); |
|
| 67 | + if ($handler instanceof CacheInterface) $manager->addProvider($handler); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | protected function getHandler($provider, $parameters) {
|
| 93 | 93 | |
| 94 | - switch ( strtolower($parameters['type']) ) {
|
|
| 94 | + switch (strtolower($parameters['type'])) {
|
|
| 95 | 95 | |
| 96 | 96 | case 'filecache': |
| 97 | 97 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected static function getAlgorithm($algorithm = null) {
|
| 123 | 123 | |
| 124 | - switch ( strtoupper($algorithm) ) {
|
|
| 124 | + switch (strtoupper($algorithm)) {
|
|
| 125 | 125 | |
| 126 | 126 | case 'PICK_LAST': |
| 127 | 127 | $selected = CacheManager::PICK_LAST; |
@@ -64,7 +64,9 @@ |
||
| 64 | 64 | |
| 65 | 65 | $handler = $this->getHandler($provider, $parameters); |
| 66 | 66 | |
| 67 | - if ( $handler instanceof CacheInterface ) $manager->addProvider($handler); |
|
| 67 | + if ( $handler instanceof CacheInterface ) { |
|
| 68 | + $manager->addProvider($handler); |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | } |
| 70 | 72 | |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | $routes = Yaml::parse($yaml); |
| 220 | 220 | |
| 221 | - if ( !empty($routes) ) { |
|
| 221 | + if (!empty($routes)) { |
|
| 222 | 222 | |
| 223 | - foreach( $routes as $name => $route ) { |
|
| 223 | + foreach ($routes as $name => $route) { |
|
| 224 | 224 | |
| 225 | 225 | $this->add($route['route'], $route['type'], $route['class'], $route['parameters']); |
| 226 | 226 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | foreach ($this->table->routes() as $regex => $value) { |
| 240 | 240 | |
| 241 | - if (preg_match("/" . $regex . "/", $path, $matches)) { |
|
| 241 | + if (preg_match("/".$regex."/", $path, $matches)) { |
|
| 242 | 242 | |
| 243 | 243 | $this->evalUri($value['query'], $matches); |
| 244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $this->classname = $value['class']; |
| 252 | 252 | $this->type = $value['type']; |
| 253 | 253 | $this->service = implode('.', $value['service']); |
| 254 | - $this->service = empty($this->service)?"default":$this->service; |
|
| 254 | + $this->service = empty($this->service) ? "default" : $this->service; |
|
| 255 | 255 | |
| 256 | 256 | return true; |
| 257 | 257 | |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | private function evalUri($parameters, $bits) { |
| 267 | 267 | |
| 268 | - $count = 0; |
|
| 268 | + $count = 0; |
|
| 269 | 269 | |
| 270 | 270 | foreach ($parameters as $key => $value) { |
| 271 | 271 | |
| 272 | 272 | if (isset($bits[$key])) { |
| 273 | 273 | |
| 274 | - if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) { |
|
| 274 | + if (preg_match('/^'.$value['regex'].'$/', $bits[$key], $matches)) { |
|
| 275 | 275 | |
| 276 | 276 | if (count($matches) == 1) $matches = $matches[0]; |
| 277 | 277 | |