@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $methods = $this->configuration->get('allowed-http-methods'); |
| 110 | 110 | |
| 111 | - if ( ( $methods != null || !empty($methods) ) && in_array($method, $methods) === false ) { |
|
| 111 | + if (($methods != null || !empty($methods)) && in_array($method, $methods) === false) { |
|
| 112 | 112 | |
| 113 | 113 | throw new DispatcherException("Method not allowed", 0, null, 405, array( |
| 114 | - "Allow" => implode(",",$methods) |
|
| 114 | + "Allow" => implode(",", $methods) |
|
| 115 | 115 | )); |
| 116 | 116 | |
| 117 | 117 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( $this->bypass_service ) { |
|
| 141 | + if ($this->bypass_service) { |
|
| 142 | 142 | |
| 143 | 143 | return; |
| 144 | 144 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $methods = $service->getImplementedMethods(); |
| 160 | 160 | |
| 161 | - if ( in_array($method, $methods) ) { |
|
| 161 | + if (in_array($method, $methods)) { |
|
| 162 | 162 | |
| 163 | 163 | $callable = $service->getMethod($method); |
| 164 | 164 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | foreach ($this->table->routes() as $regex => $value) { |
| 202 | 202 | |
| 203 | 203 | // The current uri is checked against all the global regular expressions associated with the routes |
| 204 | - if (preg_match("/" . $regex . "/", $path, $matches)) { |
|
| 204 | + if (preg_match("/".$regex."/", $path, $matches)) { |
|
| 205 | 205 | |
| 206 | 206 | /* If a route is matched, all the bits of the route string are evalued in order to create |
| 207 | 207 | * new query parameters which will be available for the service class |
@@ -105,7 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | if (!$this->bypass_routing) { |
| 107 | 107 | |
| 108 | - if (!$this->parse()) throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404); |
|
| 108 | + if (!$this->parse()) { |
|
| 109 | + throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404); |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | } |
| 111 | 113 | |
@@ -133,8 +135,9 @@ discard block |
||
| 133 | 135 | $this->extra |
| 134 | 136 | ); |
| 135 | 137 | |
| 138 | + } else { |
|
| 139 | + return null; |
|
| 136 | 140 | } |
| 137 | - else return null; |
|
| 138 | 141 | |
| 139 | 142 | } |
| 140 | 143 | |
@@ -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 . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') . $uri . "/" ); |
|
| 55 | + return ($http.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost').$uri."/"); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -32,7 +32,9 @@ |
||
| 32 | 32 | |
| 33 | 33 | $location = $this->response()->location()->get(); |
| 34 | 34 | |
| 35 | - if ( empty($location) ) throw new Exception("Invalid location, cannot redirect"); |
|
| 35 | + if ( empty($location) ) { |
|
| 36 | + throw new Exception("Invalid location, cannot redirect"); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | $this->response()->headers()->set("Location: ".$location); |
| 38 | 40 | |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | |
| 33 | 33 | $location = $this->response->location->get(); |
| 34 | 34 | |
| 35 | - if ( empty($location) ) throw new Exception("Invalid location, cannot redirect"); |
|
| 35 | + if (empty($location)) throw new Exception("Invalid location, cannot redirect"); |
|
| 36 | 36 | |
| 37 | 37 | $this->response->headers->set("Location: ".$location); |
| 38 | 38 | |
| 39 | - if ( empty($this->response->content->get()) ) { |
|
| 39 | + if (empty($this->response->content->get())) { |
|
| 40 | 40 | |
| 41 | 41 | $this->response->content->set(sprintf('<!DOCTYPE html> |
| 42 | 42 | <html> |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | // An Allow Header should be provided from DispatcherException |
| 34 | 34 | $allow = $this->response()->headers()->get('Allow'); |
| 35 | 35 | |
| 36 | - if ( is_null($allow) ) throw new Exception("Missing Allow header"); |
|
| 36 | + if (is_null($allow)) throw new Exception("Missing Allow header"); |
|
| 37 | 37 | |
| 38 | 38 | parent::consolidate(); |
| 39 | 39 | |
@@ -33,7 +33,9 @@ |
||
| 33 | 33 | // An Allow Header should be provided from DispatcherException |
| 34 | 34 | $allow = $this->response()->headers()->get('Allow'); |
| 35 | 35 | |
| 36 | - if ( is_null($allow) ) throw new Exception("Missing Allow header"); |
|
| 36 | + if ( is_null($allow) ) { |
|
| 37 | + throw new Exception("Missing Allow header"); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | parent::consolidate(); |
| 39 | 41 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $type = $this->response()->content()->type(); |
| 34 | 34 | $charset = $this->response()->content()->charset(); |
| 35 | 35 | |
| 36 | - if ( is_null($charset) ) { |
|
| 36 | + if (is_null($charset)) { |
|
| 37 | 37 | $this->response()->headers()->set("Content-type", strtolower($type)); |
| 38 | 38 | } else { |
| 39 | 39 | $this->response()->headers()->set("Content-type", strtolower($type)."; charset=".$charset); |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function set($content=null) { |
|
| 41 | + public function set($content = null) { |
|
| 42 | 42 | |
| 43 | - if ( !is_scalar($content) && $content != null ) { |
|
| 43 | + if (!is_scalar($content) && $content != null) { |
|
| 44 | 44 | |
| 45 | 45 | throw new Exception("Invalid HTTP content"); |
| 46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function type($type = null) { |
| 56 | 56 | |
| 57 | - if ( is_null($type) ) { |
|
| 57 | + if (is_null($type)) { |
|
| 58 | 58 | |
| 59 | 59 | return $this->type; |
| 60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function charset($charset = null) { |
| 70 | 70 | |
| 71 | - if ( is_null($charset) ) { |
|
| 71 | + if (is_null($charset)) { |
|
| 72 | 72 | |
| 73 | 73 | return $this->charset; |
| 74 | 74 | |
@@ -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','PURGE'); |
|
| 99 | + if (is_null($supported_methods)) $supported_methods = array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PURGE'); |
|
| 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','PURGE'); |
|
| 99 | + if ( is_null($supported_methods) ) { |
|
| 100 | + $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE'); |
|
| 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 | |
@@ -90,6 +90,11 @@ |
||
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | + /** |
|
| 94 | + * @param string $key |
|
| 95 | + * |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 93 | 98 | public function getParameter($key) { |
| 94 | 99 | |
| 95 | 100 | return (isset($this->parameters[$key]))?$this->parameters[$key]:null; |
@@ -223,7 +223,10 @@ |
||
| 223 | 223 | */ |
| 224 | 224 | if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) { |
| 225 | 225 | |
| 226 | - if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
|
| 226 | + if (count($matches) == 1) { |
|
| 227 | + $matches = $matches[0]; |
|
| 228 | + } |
|
| 229 | + // This is the case where no backreferences are present or available. |
|
| 227 | 230 | |
| 228 | 231 | // The extracted value (with any backreference available) is added to the query parameters. |
| 229 | 232 | $this->request->query()->set($key, $matches); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function getServiceName() { |
| 74 | 74 | |
| 75 | - return (empty($this->service))?"default":implode('.', $this->service); |
|
| 75 | + return (empty($this->service)) ? "default" : implode('.', $this->service); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $parameters = $this->parameters; |
| 98 | 98 | |
| 99 | - return (isset($parameters[$key]))?$parameters[$key]:null; |
|
| 99 | + return (isset($parameters[$key])) ? $parameters[$key] : null; |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $parameters = $this->request; |
| 128 | 128 | |
| 129 | - return (isset($parameters[$key]))?$parameters[$key]:null; |
|
| 129 | + return (isset($parameters[$key])) ? $parameters[$key] : null; |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | $query = $this->query; |
| 171 | 171 | |
| 172 | - return isset($query[$key])?$query[$key]["required"]:false; |
|
| 172 | + return isset($query[$key]) ? $query[$key]["required"] : false; |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $query = $this->query; |
| 179 | 179 | |
| 180 | - return isset($query[$key])?$query[$key]["regex"]:null; |
|
| 180 | + return isset($query[$key]) ? $query[$key]["regex"] : null; |
|
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /* if it's available a bit associated with the parameter name, it is compared against |
| 219 | 219 | * it's regular expression in order to extrect backreferences |
| 220 | 220 | */ |
| 221 | - if (preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches)) { |
|
| 221 | + if (preg_match('/^'.$value['regex'].'$/', $path[$key], $matches)) { |
|
| 222 | 222 | |
| 223 | 223 | if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available. |
| 224 | 224 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * @param string $data Serialized data |
| 43 | 43 | * |
| 44 | - * @return Routes $this |
|
| 44 | + * @return boolean $this |
|
| 45 | 45 | */ |
| 46 | 46 | public function unserialize($data) { |
| 47 | 47 | |