Completed
Push — 4.0 ( 4bc36a...ab2e40 )
by Marco
11:01
created
src/Comodojo/Dispatcher/Router/Route.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     public function getServiceName() {
83 83
 
84
-        return (empty($this->service))?"default":implode('.', $this->service);
84
+        return (empty($this->service)) ? "default" : implode('.', $this->service);
85 85
 
86 86
     }
87 87
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
     public function getParameter($key) {
105 105
         
106
-        return (isset($this->parameters[$key]))?$this->parameters[$key]:null;
106
+        return (isset($this->parameters[$key])) ? $this->parameters[$key] : null;
107 107
 
108 108
     }
109 109
 
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
     
143 143
     public function isQueryRequired($key) {
144 144
         
145
-        return isset($this->query[$key])?$this->query[$key]["required"]:false;
145
+        return isset($this->query[$key]) ? $this->query[$key]["required"] : false;
146 146
         
147 147
     }
148 148
     
149 149
     public function getQueryRegex($key) {
150 150
         
151
-        return isset($this->query[$key])?$this->query[$key]["regex"]:null;
151
+        return isset($this->query[$key]) ? $this->query[$key]["regex"] : null;
152 152
         
153 153
     }
154 154
     
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                 /* if it's available a bit associated with the parameter name, it is compared against
221 221
                  * it's regular expression in order to extrect backreferences
222 222
                  */
223
-                if (preg_match('/^' . $value['regex'] . '$/', $path[$key], $matches)) {
223
+                if (preg_match('/^'.$value['regex'].'$/', $path[$key], $matches)) {
224 224
                     
225 225
                     if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available.
226 226
                     
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -113,8 +113,9 @@  discard block
 block discarded – undo
113 113
                 $this->extra
114 114
             );
115 115
 
116
+        } else {
117
+            return null;
116 118
         }
117
-        else return null;
118 119
 
119 120
     }
120 121
 
@@ -294,7 +295,10 @@  discard block
 block discarded – undo
294 295
                  */
295 296
                 if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) {
296 297
                     
297
-                    if (count($matches) == 1) $matches = $matches[0]; // This is the case where no backreferences are present or available.
298
+                    if (count($matches) == 1) {
299
+                        $matches = $matches[0];
300
+                    }
301
+                    // This is the case where no backreferences are present or available.
298 302
                     
299 303
                     // The extracted value (with any backreference available) is added to the query parameters.
300 304
                     $this->request->query()->set($key, $matches);
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Router/Table.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 
151 151
     public function load($routes) {
152 152
 
153
-        if ( !empty($routes) ) {
153
+        if (!empty($routes)) {
154 154
 
155
-            foreach( $routes as $name => $route ) {
155
+            foreach ($routes as $name => $route) {
156 156
 
157 157
                 $this->add($route['route'], $route['type'], $route['class'], $route['parameters']);
158 158
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         
191 191
         $routes = array();
192 192
         
193
-        foreach($this->routes as $name => $route) {
193
+        foreach ($this->routes as $name => $route) {
194 194
             
195 195
             $routes[$name] = $route->getData();
196 196
             
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             ->setClassName($class) // Class to be invoked
214 214
             ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...)
215 215
 
216
-        $this->logger->debug("ROUTE: " . implode("/", $folders));
216
+        $this->logger->debug("ROUTE: ".implode("/", $folders));
217 217
 
218 218
         //$this->logger->debug("PARAMETERS: " . var_export($value, true));
219 219
 
220 220
         // This method generate a global regular expression which will be able to match all the URI supported by the route
221 221
         $regex = $this->parser->read($folders, $route);
222 222
 
223
-        $this->logger->debug("ROUTE: " . $regex);
223
+        $this->logger->debug("ROUTE: ".$regex);
224 224
 
225 225
         //$this->logger->debug("PARAMETERS: " . var_export($value, true));
226 226
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,10 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
         $regex = $this->regex($route);
87 87
 
88
-        if (isset($this->routes[$regex]))
89
-            return $this->routes[$regex];
90
-        else
91
-            return null;
88
+        if (isset($this->routes[$regex])) {
89
+                    return $this->routes[$regex];
90
+        } else {
91
+                    return null;
92
+        }
92 93
 
93 94
     }
94 95
 
@@ -160,7 +161,9 @@  discard block
 block discarded – undo
160 161
         
161 162
         $routes = $this->cache->get("dispatcher_routes");
162 163
         
163
-        if (is_null($routes)) return null;
164
+        if (is_null($routes)) {
165
+            return null;
166
+        }
164 167
         
165 168
         foreach ($routes as $name => $data) {
166 169
             
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Router/Model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 
93 93
         $methods = $this->configuration->get('allowed-http-methods');
94 94
 
95
-        if ( ( $methods != null || !empty($methods) ) && in_array($method, $methods) === false ) {
95
+        if (($methods != null || !empty($methods)) && in_array($method, $methods) === false) {
96 96
 
97 97
             throw new DispatcherException("Method not allowed", 0, null, 405, array(
98
-                "Allow" => implode(",",$methods)
98
+                "Allow" => implode(",", $methods)
99 99
             ));
100 100
 
101 101
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
             $methods = $service->getImplementedMethods();
138 138
 
139
-            if ( in_array($method, $methods) ) {
139
+            if (in_array($method, $methods)) {
140 140
 
141 141
                 $callable = $service->getMethod($method);
142 142
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         foreach ($this->table->routes() as $regex => $value) {
180 180
             
181 181
             // The current uri is checked against all the global regular expressions associated with the routes
182
-            if (preg_match("/" . $regex . "/", $path, $matches)) {
182
+            if (preg_match("/".$regex."/", $path, $matches)) {
183 183
 
184 184
                 /* If a route is matched, all the bits of the route string are evalued in order to create
185 185
                  * new query parameters which will be available for the service class
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,9 @@
 block discarded – undo
104 104
 
105 105
         if (!$this->bypass) {
106 106
             
107
-            if (!$this->parse()) throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404);
107
+            if (!$this->parse()) {
108
+                throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404);
109
+            }
108 110
 
109 111
         }
110 112
         
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Components/EventsManager.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function subscribe($event, $class, $method = null, $priority = 0) {
46 46
 
47
-        $callable = ( is_null($method) ) ? $class : array($class, $method);
47
+        $callable = (is_null($method)) ? $class : array($class, $method);
48 48
 
49 49
         $this->logger->debug("Subscribing handler $calss to event $event", array(
50 50
             "CALLABLE" => $callable,
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
     public function subscribeOnce($event, $class, $method = null, $priority = 0) {
59 59
 
60
-        $callable = ( is_null($method) ) ? $class : array($class, $method);
60
+        $callable = (is_null($method)) ? $class : array($class, $method);
61 61
 
62 62
         $this->logger->debug("Subscribing once handler $calss to event $event", array(
63 63
             "CALLABLE" => $callable,
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function unsubscribe($event, $class = null, $method = null) {
72 72
 
73
-        if ( is_null($class) ) {
73
+        if (is_null($class)) {
74 74
 
75 75
             $this->logger->debug("Unsubscribing all handlers from event $event");
76 76
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
         } else {
80 80
 
81
-            $callable = ( is_null($method) ) ? $class : array($class, $method);
81
+            $callable = (is_null($method)) ? $class : array($class, $method);
82 82
 
83 83
             $this->logger->debug("Unsubscribing handler $calss from event $event", array(
84 84
                 "CALLABLE" => $callable
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 
93 93
     public function load($plugins) {
94 94
 
95
-        if ( !empty($plugins) ) {
95
+        if (!empty($plugins)) {
96 96
 
97
-            foreach( $plugins as $name => $event ) {
97
+            foreach ($plugins as $name => $event) {
98 98
 
99
-                $callable = ( is_null($event['method']) ) ? $event["class"] : array($event["class"], $event["method"]);
99
+                $callable = (is_null($event['method'])) ? $event["class"] : array($event["class"], $event["method"]);
100 100
 
101 101
                 $this->addListener($event["event"], $callable, $event["priority"]);
102 102
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Components/CacheManager.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 30
  */
31 31
 
32
-class CacheManager extends DispatcherClassModel{
32
+class CacheManager extends DispatcherClassModel {
33 33
 
34 34
     public function init() {
35 35
 
36 36
         $cache = $this->configuration()->get('cache');
37 37
 
38
-        if ( empty($cache) ) {
38
+        if (empty($cache)) {
39 39
 
40 40
             $manager = new ComodojoCacheManager(self::getAlgorithm(), $this->logger);
41 41
 
42 42
         } else {
43 43
 
44
-            $enabled = ( empty($cache['enabled']) || $cache['enabled'] === true ) ? true : false;
44
+            $enabled = (empty($cache['enabled']) || $cache['enabled'] === true) ? true : false;
45 45
 
46
-            $algorithm = self::getAlgorithm( empty($cache['algorithm']) ? null : $cache['algorithm']);
46
+            $algorithm = self::getAlgorithm(empty($cache['algorithm']) ? null : $cache['algorithm']);
47 47
 
48 48
             $manager = new ComodojoCacheManager($algorithm, $this->logger);
49 49
 
50
-            if ( $enabled && !empty($cache['providers']) ) {
50
+            if ($enabled && !empty($cache['providers'])) {
51 51
 
52 52
                 foreach ($cache['providers'] as $provider => $parameters) {
53 53
 
54 54
                     $handler = $this->getHandler($provider, $parameters);
55 55
 
56
-                    if ( $handler instanceof CacheInterface ) $manager->addProvider($handler);
56
+                    if ($handler instanceof CacheInterface) $manager->addProvider($handler);
57 57
 
58 58
                 }
59 59
 
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 
81 81
     protected function getHandler($provider, $parameters) {
82 82
 
83
-        switch ( strtolower($parameters['type']) ) {
83
+        switch (strtolower($parameters['type'])) {
84 84
 
85 85
             case 'filecache':
86 86
 
87 87
                 $base = $this->configuration->get('base-path');
88 88
 
89
-                if ( empty($parameters['folder']) ||  empty($base) ) {
89
+                if (empty($parameters['folder']) || empty($base)) {
90 90
                     $this->logger->warning("Wrong cache provider, disabling $provider", $parameters);
91 91
                     break;
92 92
                 }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
             case 'memcached':
101 101
 
102
-                if ( empty($parameters['host']) ) {
102
+                if (empty($parameters['host'])) {
103 103
                     $this->logger->warning("Wrong cache provider, disabling $provider", $parameters);
104 104
                     break;
105 105
                 }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     protected static function getAlgorithm($algorithm = null) {
134 134
 
135
-        switch ( strtoupper($algorithm) ) {
135
+        switch (strtoupper($algorithm)) {
136 136
 
137 137
             case 'PICK_LAST':
138 138
                 $selected = ComodojoCacheManager::PICK_LAST;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.