@@ -66,8 +66,6 @@ |
||
66 | 66 | /** |
67 | 67 | * Map provided log level to level code |
68 | 68 | * |
69 | - * @param string $level |
|
70 | - * |
|
71 | 69 | * @return integer |
72 | 70 | */ |
73 | 71 | protected static function getAlgorithm($algorithm) { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $ttl = $configuration->get('dispatcher-cache-ttl'); |
43 | 43 | |
44 | - if ( $ttl !== null && !defined('COMODOJO_CACHE_DEFAULT_TTL') ) { |
|
44 | + if ($ttl !== null && !defined('COMODOJO_CACHE_DEFAULT_TTL')) { |
|
45 | 45 | |
46 | 46 | define('COMODOJO_CACHE_DEFAULT_TTL', $ttl); |
47 | 47 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | |
50 | 50 | $folder = $configuration->get('dispatcher-cache-folder'); |
51 | 51 | |
52 | - $algorithm = self::getAlgorithm( $configuration->get('dispatcher-cache-algorithm') ); |
|
52 | + $algorithm = self::getAlgorithm($configuration->get('dispatcher-cache-algorithm')); |
|
53 | 53 | |
54 | - $manager = new CacheManager( $algorithm ); |
|
54 | + $manager = new CacheManager($algorithm); |
|
55 | 55 | |
56 | - if ( $enabled === true ) { |
|
56 | + if ($enabled === true) { |
|
57 | 57 | |
58 | - $manager->addProvider( new FileCache($folder) ); |
|
58 | + $manager->addProvider(new FileCache($folder)); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected static function getAlgorithm($algorithm) { |
74 | 74 | |
75 | - switch ( strtoupper($algorithm) ) { |
|
75 | + switch (strtoupper($algorithm)) { |
|
76 | 76 | |
77 | 77 | case 'PICK_LAST': |
78 | 78 | $selected = CacheManager::PICK_LAST; |
@@ -33,8 +33,6 @@ |
||
33 | 33 | /** |
34 | 34 | * Create the logger |
35 | 35 | * |
36 | - * @param bool $verbose |
|
37 | - * |
|
38 | 36 | * @return \Monolog\Logger |
39 | 37 | */ |
40 | 38 | public static function create(Configuration $configuration) { |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | |
44 | 44 | $enabled = $configuration->get('dispatcher-log-enabled'); |
45 | 45 | |
46 | - $level = self::getLevel( $configuration->get('dispatcher-log-level') ); |
|
46 | + $level = self::getLevel($configuration->get('dispatcher-log-level')); |
|
47 | 47 | |
48 | 48 | $target = $configuration->get('dispatcher-log-target'); |
49 | 49 | |
50 | 50 | $logger = new Logger($name); |
51 | 51 | |
52 | - if ( $enabled === true ) { |
|
52 | + if ($enabled === true) { |
|
53 | 53 | |
54 | - $logger->pushHandler( new StreamHandler( $target, $level) ); |
|
54 | + $logger->pushHandler(new StreamHandler($target, $level)); |
|
55 | 55 | |
56 | 56 | } else { |
57 | 57 | |
58 | - $logger->pushHandler( new NullHandler($level) ); |
|
58 | + $logger->pushHandler(new NullHandler($level)); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected static function getLevel($level) { |
74 | 74 | |
75 | - switch ( strtoupper($level) ) { |
|
75 | + switch (strtoupper($level)) { |
|
76 | 76 | |
77 | 77 | case 'INFO': |
78 | 78 | $logger_level = Logger::INFO; |
@@ -62,6 +62,9 @@ |
||
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | + /** |
|
66 | + * @param string $route |
|
67 | + */ |
|
65 | 68 | public function get($route) { |
66 | 69 | |
67 | 70 | $folders = explode("/", $route); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->readpath( |
129 | 129 | $folders, |
130 | 130 | $value, |
131 | - $regex.'(?:\/'.$param_regex.')'. (($param_required)?'{1}':'?') |
|
131 | + $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?') |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | } else { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $string = preg_replace('/(?<!\\)\((?!\?)/', '(?:', $string); |
172 | 172 | $string = preg_replace('/\.([\*\+])(?!\?)/', '.\${1}?', $string); |
173 | 173 | |
174 | - return '(?P<' . $key . '>' . $string . ')' . (($field_required)?'{1}':'?'); |
|
174 | + return '(?P<'.$key.'>'.$string.')'.(($field_required) ? '{1}' : '?'); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 |
@@ -66,10 +66,11 @@ discard block |
||
66 | 66 | |
67 | 67 | $regex = $this->readpath($folders); |
68 | 68 | |
69 | - if (isset($this->routes[$regex])) |
|
70 | - return $this->routes[$regex]; |
|
71 | - else |
|
72 | - return null; |
|
69 | + if (isset($this->routes[$regex])) { |
|
70 | + return $this->routes[$regex]; |
|
71 | + } else { |
|
72 | + return null; |
|
73 | + } |
|
73 | 74 | |
74 | 75 | } |
75 | 76 | |
@@ -79,7 +80,9 @@ discard block |
||
79 | 80 | |
80 | 81 | $regex = $this->readpath($folders); |
81 | 82 | |
82 | - if (isset($this->routes[$regex])) unset($this->routes[$regex]); |
|
83 | + if (isset($this->routes[$regex])) { |
|
84 | + unset($this->routes[$regex]); |
|
85 | + } |
|
83 | 86 | |
84 | 87 | } |
85 | 88 | |
@@ -97,7 +100,9 @@ discard block |
||
97 | 100 | |
98 | 101 | private function readpath($folders = array(), &$value = null, $regex = '') { |
99 | 102 | |
100 | - if (!empty($folders) && empty($folders[0])) array_shift($folders); |
|
103 | + if (!empty($folders) && empty($folders[0])) { |
|
104 | + array_shift($folders); |
|
105 | + } |
|
101 | 106 | |
102 | 107 | if (empty($folders)) { |
103 | 108 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | 'dispatcher-log-level' => 'INFO', |
35 | 35 | 'dispatcher-log-target' => '%dispatcher-log-folder%/dispatcher.log', |
36 | 36 | 'dispatcher-log-folder' => '/log', |
37 | - 'dispatcher-supported-methods' => array('GET','PUT','POST','DELETE','OPTIONS','HEAD'), |
|
37 | + 'dispatcher-supported-methods' => array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD'), |
|
38 | 38 | 'dispatcher-default-encoding' => 'UTF-8', |
39 | 39 | 'dispatcher-cache-enabled' => true, |
40 | 40 | 'dispatcher-cache-ttl' => 3600, |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | //'dispatcher-autoroute' => false |
45 | 45 | ); |
46 | 46 | |
47 | - public function __construct( $configuration = array() ) { |
|
47 | + public function __construct($configuration = array()) { |
|
48 | 48 | |
49 | 49 | $this->attributes['dispatcher-base-url'] = self::urlGetAbsolute(); |
50 | 50 | |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | |
61 | 61 | $value = $this->attributes[$property]; |
62 | 62 | |
63 | - if ( is_scalar($value) && preg_match_all('/%(.+?)%/', $value, $matches) ) { |
|
63 | + if (is_scalar($value) && preg_match_all('/%(.+?)%/', $value, $matches)) { |
|
64 | 64 | |
65 | 65 | $substitutions = array(); |
66 | 66 | |
67 | - foreach ( $matches as $match ) { |
|
67 | + foreach ($matches as $match) { |
|
68 | 68 | |
69 | 69 | $backreference = $match[1]; |
70 | 70 | |
71 | - if ( $backreference != $property && !isset($substitutions['/%'.$backreference.'%/']) ) { |
|
71 | + if ($backreference != $property && !isset($substitutions['/%'.$backreference.'%/'])) { |
|
72 | 72 | |
73 | 73 | $substitutions['/%'.$backreference.'%/'] = $this->$backreference; |
74 | 74 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | |
113 | 113 | private static function urlGetAbsolute() { |
114 | 114 | |
115 | - $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://'; |
|
115 | + $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://'; |
|
116 | 116 | |
117 | 117 | $uri = preg_replace("/\/index.php(.*?)$/i", "", $_SERVER['PHP_SELF']); |
118 | 118 | |
119 | - return ( $http . $_SERVER['HTTP_HOST'] . $uri . "/" ); |
|
119 | + return ($http.$_SERVER['HTTP_HOST'].$uri."/"); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $supported_methods = $this->configuration()->get('dispatcher-supported-methods'); |
96 | 96 | |
97 | - if ( method_exists($this, 'any') ) { |
|
97 | + if (method_exists($this, 'any')) { |
|
98 | 98 | |
99 | 99 | return $supported_methods; |
100 | 100 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | |
103 | 103 | $implemented_methods = array(); |
104 | 104 | |
105 | - foreach ( $supported_methods as $method ) { |
|
105 | + foreach ($supported_methods as $method) { |
|
106 | 106 | |
107 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
107 | + if (method_exists($this, strtolower($method))) array_push($implemented_methods, $method); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | */ |
119 | 119 | final public function getMethod($method) { |
120 | 120 | |
121 | - if ( method_exists($this, strtolower($method)) ) { |
|
121 | + if (method_exists($this, strtolower($method))) { |
|
122 | 122 | |
123 | 123 | return strtolower($method); |
124 | 124 | |
125 | - } else if ( method_exists($this, strtolower('any')) ) { |
|
125 | + } else if (method_exists($this, strtolower('any'))) { |
|
126 | 126 | |
127 | 127 | return 'any'; |
128 | 128 |
@@ -104,7 +104,9 @@ |
||
104 | 104 | |
105 | 105 | foreach ( $supported_methods as $method ) { |
106 | 106 | |
107 | - if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method); |
|
107 | + if ( method_exists($this, strtolower($method)) ) { |
|
108 | + array_push($implemented_methods,$method); |
|
109 | + } |
|
108 | 110 | |
109 | 111 | } |
110 | 112 |