Completed
Push — 4.0 ( 7ee5d6...ad8a54 )
by Marco
02:43
created
src/Comodojo/Dispatcher/Output/HttpStatus/Status204.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
         header($_SERVER["SERVER_PROTOCOL"].' 204 No Content');
32 32
         header('Status: 204 No Content');
33
-        header('Content-Length: 0',true);
33
+        header('Content-Length: 0', true);
34 34
 
35 35
         $this->response()->content()->set(null);
36 36
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Output/HttpStatus/Status201.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
     public function consolidate() {
30 30
 
31
-        header("Location: ".$this->response()->location()->get(),true,$this->response()->status()->get());
31
+        header("Location: ".$this->response()->location()->get(), true, $this->response()->status()->get());
32 32
 
33 33
     }
34 34
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Output/HttpStatus/Status405.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         // An Allow Header should be prvided from DispatcherException
32 32
         $allowed = $this->response()->headers()->get('Allow');
33 33
 
34
-        if ( is_null($allowed) ) {
34
+        if (is_null($allowed)) {
35 35
 
36 36
             header('Method not allowed', true, 405);
37 37
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Output/HttpStatus/Status501.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         // An Allow Header should be prvided from DispatcherException
32 32
         $allowed = $this->response()->headers()->get('Allow');
33 33
 
34
-        if ( is_null($allowed) ) {
34
+        if (is_null($allowed)) {
35 35
 
36 36
             header('Method not allowed', true, 405);
37 37
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Router/Parser.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
                  */
74 74
                 foreach ($decoded as $key => $string) {
75 75
 
76
-                    $this->logger->debug("PARAMETER KEY: " . $key);
76
+                    $this->logger->debug("PARAMETER KEY: ".$key);
77 77
 
78
-                    $this->logger->debug("PARAMETER STRING: " . $string);
78
+                    $this->logger->debug("PARAMETER STRING: ".$string);
79 79
                     
80 80
                     /* The key and the regex of every paramater is passed to the 'param'
81 81
                      * method which will build an appropriate regular expression and will understand 
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
                      */
84 84
                     $param_regex .= $this->param($key, $string, $param_required, $value);
85 85
 
86
-                    $this->logger->debug("PARAMETER REGEX: " . $param_regex);
86
+                    $this->logger->debug("PARAMETER REGEX: ".$param_regex);
87 87
 
88 88
                 }
89 89
                 // Once the parameter is analyzed, the result is passed to the next iteration
90 90
                 return $this->read(
91 91
                     $folders,
92 92
                     $value,
93
-                    $regex.'(?:\/'.$param_regex.')'. (($param_required)?'{1}':'?')
93
+                    $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?')
94 94
                 );
95 95
 
96 96
             } else {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
          * If the field is required, the regular expression is completed with a '{1}' (which make it compulsory),
156 156
          * otherwise a '?' is added.
157 157
          */
158
-        return '(?P<' . $key . '>' . $string . ')' . (($field_required)?'{1}':'?');
158
+        return '(?P<'.$key.'>'.$string.')'.(($field_required) ? '{1}' : '?');
159 159
 
160 160
     }
161 161
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,9 @@
 block discarded – undo
103 103
                      */
104 104
                     $param_regex .= $this->param($key, $string, $value);
105 105
                     
106
-                    if ($value->isQueryRequired($key)) $param_required = true;
106
+                    if ($value->isQueryRequired($key)) {
107
+                        $param_required = true;
108
+                    }
107 109
 
108 110
                     $this->logger->debug("PARAMETER REGEX: " . $param_regex);
109 111
 
Please login to merge, or discard this patch.
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/Model.php 2 patches
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.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
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.
src/Comodojo/Dispatcher/Components/EventsManager.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
         $callable = $this->convertToListener($class, $event);
49 49
 
50
-        if ( $callable === false ) return null;
50
+        if ($callable === false) return null;
51 51
 
52 52
         return $this->addListener($event, $callable, $priority);
53 53
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         $callable = $this->convertToListener($class, $event);
59 59
 
60
-        if ( $callable === false ) return null;
60
+        if ($callable === false) return null;
61 61
 
62 62
         return $this->addOneTimeListener($event, $callable, $priority);
63 63
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
     protected function convertToListener($class, $event) {
67 67
 
68
-        if ( !class_exists($class) ) {
68
+        if (!class_exists($class)) {
69 69
 
70 70
             $this->logger->error("Cannot subscribe class $class to event $event: cannot find class");
71 71
 
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function load($plugins) {
93 93
 
94
-        if ( !empty($plugins) ) {
94
+        if (!empty($plugins)) {
95 95
 
96
-            foreach( $plugins as $name => $plugin ) {
96
+            foreach ($plugins as $name => $plugin) {
97 97
 
98
-                if ( !isset($plugin['class']) || !isset($plugin["event"]) ) {
98
+                if (!isset($plugin['class']) || !isset($plugin["event"])) {
99 99
 
100 100
                     $this->logger->error("Invalid plugin definition", $plugin);
101 101
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 $priority = isset($plugin['priority']) ? $plugin['priority'] : 0;
107 107
                 $onetime = isset($plugin['onetime']) ? $plugin['onetime'] : 0;
108 108
 
109
-                if ( $onetime ) $this->subscribeOnce($plugin['event'], $plugin['class'], $priority);
109
+                if ($onetime) $this->subscribeOnce($plugin['event'], $plugin['class'], $priority);
110 110
                 else $this->subscribe($plugin['event'], $plugin['class'], $priority);
111 111
 
112 112
             }
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@  discard block
 block discarded – undo
47 47
 
48 48
         $callable = $this->convertToListener($class, $event);
49 49
 
50
-        if ( $callable === false ) return null;
50
+        if ( $callable === false ) {
51
+            return null;
52
+        }
51 53
 
52 54
         return $this->addListener($event, $callable, $priority);
53 55
 
@@ -57,7 +59,9 @@  discard block
 block discarded – undo
57 59
 
58 60
         $callable = $this->convertToListener($class, $event);
59 61
 
60
-        if ( $callable === false ) return null;
62
+        if ( $callable === false ) {
63
+            return null;
64
+        }
61 65
 
62 66
         return $this->addOneTimeListener($event, $callable, $priority);
63 67
 
@@ -106,8 +110,11 @@  discard block
 block discarded – undo
106 110
                 $priority = isset($plugin['priority']) ? $plugin['priority'] : 0;
107 111
                 $onetime = isset($plugin['onetime']) ? $plugin['onetime'] : 0;
108 112
 
109
-                if ( $onetime ) $this->subscribeOnce($plugin['event'], $plugin['class'], $priority);
110
-                else $this->subscribe($plugin['event'], $plugin['class'], $priority);
113
+                if ( $onetime ) {
114
+                    $this->subscribeOnce($plugin['event'], $plugin['class'], $priority);
115
+                } else {
116
+                    $this->subscribe($plugin['event'], $plugin['class'], $priority);
117
+                }
111 118
 
112 119
             }
113 120
 
Please login to merge, or discard this patch.