Completed
Branch master (9c4346)
by Patrick
10:57
created
Auth/OAuth2/class.GitHubAuthenticator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
 
31 31
     public function getUserFromToken($token)
32 32
     {
33
-        if($token === false)
33
+        if ($token === false)
34 34
         {
35 35
             $token = \FlipSession::getVar('OAuthToken');
36 36
         }
37 37
         $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send();
38 38
         $github_user = $resp->body;
39 39
         $user = new \Auth\PendingUser();
40
-        if(isset($github_user->name))
40
+        if (isset($github_user->name))
41 41
         {
42 42
             $name = explode(' ', $github_user->name);
43 43
             $user->setGivenName($name[0]);
Please login to merge, or discard this patch.
Auth/class.NullAuthenticator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
     public function isLoggedIn($data)
12 12
     {
13
-        if(isset($data['res']))
13
+        if (isset($data['res']))
14 14
         {
15 15
             return $data['res'];
16 16
         }
Please login to merge, or discard this patch.
class.FlipREST.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     private function getUserFromSession()
27 27
     {
28
-        if(FlipSession::isLoggedIn())
28
+        if (FlipSession::isLoggedIn())
29 29
         {
30 30
             return FlipSession::getUser();
31 31
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $auth = \AuthProvider::getInstance();
42 42
         $auth->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
43 43
         $user = FlipSession::getUser();
44
-        if($user === false)
44
+        if ($user === false)
45 45
         {
46 46
             $data = substr($header['Authorization'], 6);
47 47
             $userpass = explode(':', base64_decode($data));
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     private function getUserFromHeader($header)
64 64
     {
65
-        if(strncmp($header, 'Basic', 5) == 0)
65
+        if (strncmp($header, 'Basic', 5) == 0)
66 66
         {
67 67
             return $this->getUserFromBasicAuth($header);
68 68
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     public function call()
73 73
     {
74 74
         // no auth header
75
-        if(!isset($this->headers['Authorization']))
75
+        if (!isset($this->headers['Authorization']))
76 76
         {
77 77
             $this->app->user = $this->getUserFromSession();
78 78
         } 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             $this->app->user = $this->getUserFromHeader($header);
83 83
         }
84 84
 
85
-        if($this->app->user === false)
85
+        if ($this->app->user === false)
86 86
         {
87 87
             $this->app->getLog()->error("No user found for call");
88 88
         }
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 {
97 97
     private function fix_encoded_element($key, $value, &$array, $prefix = '')
98 98
     {
99
-        if(is_array($value))
99
+        if (is_array($value))
100 100
         {
101 101
             $array[$key] = implode(';', $value);
102 102
         }
103
-        else if($key === '_id' && is_object($value))
103
+        else if ($key === '_id' && is_object($value))
104 104
         {
105 105
             $array[$key] = $value->{'$id'};
106 106
         }
107
-        else if(is_object($value))
107
+        else if (is_object($value))
108 108
         {
109 109
             $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key;
110 110
         }
111
-        else if(strncmp($value, 'data:', 5) === 0)
111
+        else if (strncmp($value, 'data:', 5) === 0)
112 112
         {
113 113
             $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key;
114 114
         }
@@ -122,40 +122,40 @@  discard block
 block discarded – undo
122 122
         }
123 123
         ob_start();
124 124
         $df = fopen("php://output", 'w');
125
-        if(is_array($array))
125
+        if (is_array($array))
126 126
         {
127 127
             $first = reset($array);
128 128
             $keys = FALSE;
129
-            if(is_array($first))
129
+            if (is_array($first))
130 130
             {
131 131
                 $keys = array_keys($first);
132 132
             }
133
-            else if(is_object($first))
133
+            else if (is_object($first))
134 134
             {
135 135
                 $keys = array_keys(get_object_vars($first));
136 136
             }
137 137
             fputcsv($df, $keys);
138 138
             foreach ($array as $row)
139 139
             {
140
-                if(is_array($row))
140
+                if (is_array($row))
141 141
                 {
142 142
                     $id = $row[$keys[0]];
143
-                    foreach($row as $key=>$value)
143
+                    foreach ($row as $key=>$value)
144 144
                     {
145 145
                         $this->fix_encoded_element($key, $value, $row, '/'.$id);
146 146
                     }
147 147
                     fputcsv($df, $row);
148 148
                 }
149
-                else if(is_object($row))
149
+                else if (is_object($row))
150 150
                 {
151 151
                     $keyName = $keys[0];
152 152
                     $id = $row->$keyName;
153
-                    if(is_object($id))
153
+                    if (is_object($id))
154 154
                     {
155 155
                         $id = $id->{'$id'};
156 156
                     }
157 157
                     $values = get_object_vars($row);
158
-                    foreach($values as $key=>$value)
158
+                    foreach ($values as $key=>$value)
159 159
                     {
160 160
                         $this->fix_encoded_element($key, $value, $values, '/'.$id);
161 161
                     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         {
168 168
             $array = get_object_vars($array);
169 169
             fputcsv($df, array_keys($array));
170
-            foreach($array as $key=>$value)
170
+            foreach ($array as $key=>$value)
171 171
             {
172 172
                 $this->fix_encoded_element($key, $value, $array);
173 173
             }
@@ -185,34 +185,34 @@  discard block
 block discarded – undo
185 185
 
186 186
     public function call()
187 187
     {
188
-        if($this->app->request->isOptions())
188
+        if ($this->app->request->isOptions())
189 189
         {
190 190
             return;
191 191
         }
192 192
         $params = $this->app->request->params();
193 193
         $fmt = null;
194
-        if(isset($params['fmt']))
194
+        if (isset($params['fmt']))
195 195
         {
196 196
             $fmt = $params['fmt'];
197 197
         }
198
-        if($fmt === null && isset($params['$format']))
198
+        if ($fmt === null && isset($params['$format']))
199 199
         {
200 200
             $fmt = $params['$format'];
201
-            if(strstr($fmt, 'odata.streaming=true'))
201
+            if (strstr($fmt, 'odata.streaming=true'))
202 202
             {
203 203
                 $this->app->response->setStatus(406);
204 204
                 return;
205 205
             }
206 206
         }
207
-        if($fmt === null)
207
+        if ($fmt === null)
208 208
         {
209 209
             $mimeType = $this->app->request->headers->get('Accept');
210
-            if(strstr($mimeType, 'odata.streaming=true'))
210
+            if (strstr($mimeType, 'odata.streaming=true'))
211 211
             {
212 212
                 $this->app->response->setStatus(406);
213 213
                 return;
214 214
             }
215
-            switch($mimeType)
215
+            switch ($mimeType)
216 216
             {
217 217
                 case 'text/csv':
218 218
                     $fmt = 'csv';
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 
233 233
         $this->next->call();
234 234
 
235
-        if($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json')
235
+        if ($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json')
236 236
         {
237 237
             $data = json_decode($this->app->response->getBody());
238 238
             $text = '';
239
-            switch($this->app->fmt)
239
+            switch ($this->app->fmt)
240 240
             {
241 241
                 case 'data-table':
242 242
                     $this->app->response->headers->set('Content-Type', 'application/json');
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             }
264 264
             $this->app->response->setBody($text);
265 265
         }
266
-        else if($this->app->response->getStatus() == 200)
266
+        else if ($this->app->response->getStatus() == 200)
267 267
         {
268 268
             $this->app->response->headers->set('Content-Type', 'application/json;odata.metadata=none');
269 269
         }
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
         return $this->post($uri, $handler);
294 294
     }
295 295
 
296
-    function get_json_body($array=false)
296
+    function get_json_body($array = false)
297 297
     {
298 298
         return $this->getJsonBody($array);
299 299
     }
300 300
 
301
-    function getJsonBody($array=false)
301
+    function getJsonBody($array = false)
302 302
     {
303 303
         $body = $this->request->getBody();
304 304
         return json_decode($body, $array);
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -75,8 +75,7 @@  discard block
 block discarded – undo
75 75
         if(!isset($this->headers['Authorization']))
76 76
         {
77 77
             $this->app->user = $this->getUserFromSession();
78
-        } 
79
-        else 
78
+        } else 
80 79
         {
81 80
             $header = $this->headers['Authorization'];
82 81
             $this->app->user = $this->getUserFromHeader($header);
@@ -99,16 +98,13 @@  discard block
 block discarded – undo
99 98
         if(is_array($value))
100 99
         {
101 100
             $array[$key] = implode(';', $value);
102
-        }
103
-        else if($key === '_id' && is_object($value))
101
+        } else if($key === '_id' && is_object($value))
104 102
         {
105 103
             $array[$key] = $value->{'$id'};
106
-        }
107
-        else if(is_object($value))
104
+        } else if(is_object($value))
108 105
         {
109 106
             $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key;
110
-        }
111
-        else if(strncmp($value, 'data:', 5) === 0)
107
+        } else if(strncmp($value, 'data:', 5) === 0)
112 108
         {
113 109
             $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key;
114 110
         }
@@ -129,8 +125,7 @@  discard block
 block discarded – undo
129 125
             if(is_array($first))
130 126
             {
131 127
                 $keys = array_keys($first);
132
-            }
133
-            else if(is_object($first))
128
+            } else if(is_object($first))
134 129
             {
135 130
                 $keys = array_keys(get_object_vars($first));
136 131
             }
@@ -145,8 +140,7 @@  discard block
 block discarded – undo
145 140
                         $this->fix_encoded_element($key, $value, $row, '/'.$id);
146 141
                     }
147 142
                     fputcsv($df, $row);
148
-                }
149
-                else if(is_object($row))
143
+                } else if(is_object($row))
150 144
                 {
151 145
                     $keyName = $keys[0];
152 146
                     $id = $row->$keyName;
@@ -162,8 +156,7 @@  discard block
 block discarded – undo
162 156
                     fputcsv($df, $values);
163 157
                 }
164 158
             }
165
-        }
166
-        else
159
+        } else
167 160
         {
168 161
             $array = get_object_vars($array);
169 162
             fputcsv($df, array_keys($array));
@@ -262,8 +255,7 @@  discard block
 block discarded – undo
262 255
                     break;
263 256
             }
264 257
             $this->app->response->setBody($text);
265
-        }
266
-        else if($this->app->response->getStatus() == 200)
258
+        } else if($this->app->response->getStatus() == 200)
267 259
         {
268 260
             $this->app->response->headers->set('Content-Type', 'application/json;odata.metadata=none');
269 261
         }
Please login to merge, or discard this patch.
Autoload.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
     {
27 27
         $namespace = substr($classname, 0, $lastNsPos);
28 28
         $classname = substr($classname, $lastNsPos + 1);
29
-        $filename  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
29
+        $filename  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR;
30 30
     }
31 31
     $filename = __DIR__.DIRECTORY_SEPARATOR.$filename.'class.'.$classname.'.php';
32
-    if(is_readable($filename))
32
+    if (is_readable($filename))
33 33
     {
34 34
         require $filename;
35 35
     }
36 36
 }
37 37
 
38
-if(version_compare(PHP_VERSION, '5.3.0', '>='))
38
+if (version_compare(PHP_VERSION, '5.3.0', '>='))
39 39
 {
40 40
     spl_autoload_register('FlipsideAutoload', true, true);
41 41
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@
 block discarded – undo
38 38
 if(version_compare(PHP_VERSION, '5.3.0', '>='))
39 39
 {
40 40
     spl_autoload_register('FlipsideAutoload', true, true);
41
-}
42
-else
41
+} else
43 42
 {
44 43
     spl_autoload_register('FlipsideAutoload');
45 44
 }
Please login to merge, or discard this patch.
Data/class.DataTable.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@  discard block
 block discarded – undo
5 5
 {
6 6
     protected $data = null;
7 7
 
8
-    function count($filter=false)
8
+    function count($filter = false)
9 9
     {
10 10
         throw new \Exception('Unimplemented');
11 11
     }
12 12
 
13
-    function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false)
13
+    function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false)
14 14
     {
15
-        if($this->data === null)
15
+        if ($this->data === null)
16 16
         {
17 17
             throw new \Exception('Unimplemented');
18 18
         }
19
-        if($filter !== false)
19
+        if ($filter !== false)
20 20
         {
21 21
             $array = $filter->filter_array($this->data);
22 22
         }
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         throw new \Exception('Unimplemented');
29 29
     }
30 30
 
31
-    function read($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false)
31
+    function read($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false)
32 32
     {
33 33
         return $this->search($filter, $select, $count, $skip, $sort, $params);
34 34
     }
Please login to merge, or discard this patch.
Data/class.Filter.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
     function __construct($string = false)
11 11
     {
12
-        if($string !== false)
12
+        if ($string !== false)
13 13
         {
14 14
             $this->string = $string;
15 15
             $this->children = self::process_string($this->string);
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
     {
21 21
         $parens = false;
22 22
         //First check for parenthesis...
23
-        if($string[0] === '(' && substr($string, -1) === ')')
23
+        if ($string[0] === '(' && substr($string, -1) === ')')
24 24
         {
25
-            $string = substr($string, 1, strlen($string)-2);
25
+            $string = substr($string, 1, strlen($string) - 2);
26 26
             $parens = true;
27 27
         }
28
-        if(preg_match('/(.+?)( and | or )(.+)/', $string, $clauses) === 0)
28
+        if (preg_match('/(.+?)( and | or )(.+)/', $string, $clauses) === 0)
29 29
         {
30 30
             return array(new FilterClause($string));
31 31
         }
32 32
         $children = array();
33
-        if($parens) array_push($children, '(');
33
+        if ($parens) array_push($children, '(');
34 34
         $children = array_merge($children, self::process_string($clauses[1]));
35 35
         array_push($children, trim($clauses[2]));
36 36
         $children = array_merge($children, self::process_string($clauses[3]));
37
-        if($parens) array_push($children, ')');
37
+        if ($parens) array_push($children, ')');
38 38
         return $children;
39 39
     }
40 40
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $ret = '';
44 44
         $count = count($this->children);
45
-        for($i = 0; $i < $count; $i++)
45
+        for ($i = 0; $i < $count; $i++)
46 46
         {
47
-            if($this->children[$i] === '(' || $this->children[$i] === ')')
47
+            if ($this->children[$i] === '(' || $this->children[$i] === ')')
48 48
             {
49
-                $ret.=$this->children[$i];
49
+                $ret .= $this->children[$i];
50 50
             }
51
-            else if($this->children[$i] === 'and')
51
+            else if ($this->children[$i] === 'and')
52 52
             {
53
-                $ret.=' AND ';
53
+                $ret .= ' AND ';
54 54
             }
55
-            else if($this->children[$i] === 'or')
55
+            else if ($this->children[$i] === 'or')
56 56
             {
57
-                $ret.=' OR ';
57
+                $ret .= ' OR ';
58 58
             }
59 59
             else
60 60
             {
61
-                $ret.=$this->children[$i]->to_sql_string();
61
+                $ret .= $this->children[$i]->to_sql_string();
62 62
             }
63 63
         }
64 64
         return $ret.$this->sqlAppend;
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
         $ret = '';
70 70
         $count = count($this->children);
71 71
         $prefix = '';
72
-        for($i = 0; $i < $count; $i++)
72
+        for ($i = 0; $i < $count; $i++)
73 73
         {
74
-            if($this->children[$i] === 'and')
74
+            if ($this->children[$i] === 'and')
75 75
             {
76
-                if($prefix == '|')
76
+                if ($prefix == '|')
77 77
                 {
78 78
                     throw new \Exception('Do not support both and or');
79 79
                 }
80 80
                 $prefix = '&';
81 81
             }
82
-            else if($this->children[$i] === 'or')
82
+            else if ($this->children[$i] === 'or')
83 83
             {
84
-                if($prefix == '&')
84
+                if ($prefix == '&')
85 85
                 {
86 86
                     throw new \Exception('Do not support both and or');
87 87
                 }
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
             }
90 90
             else
91 91
             {
92
-                $ret.=$this->children[$i]->to_ldap_string();
92
+                $ret .= $this->children[$i]->to_ldap_string();
93 93
             }
94 94
         }
95
-        if($count === 1 && $prefix === '')
95
+        if ($count === 1 && $prefix === '')
96 96
         {
97 97
             return $ret;
98 98
         }
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $ret = array();
105 105
         $count = count($this->children);
106
-        for($i = 0; $i < $count; $i++)
106
+        for ($i = 0; $i < $count; $i++)
107 107
         {
108
-            if($this->children[$i] === 'and')
108
+            if ($this->children[$i] === 'and')
109 109
             {
110 110
                 $old = array_pop($ret);
111 111
                 array_push($ret, array('$and'=>array($old, $this->children[++$i]->to_mongo_filter())));
112 112
             }
113
-            else if($this->children[$i] === 'or')
113
+            else if ($this->children[$i] === 'or')
114 114
             {
115 115
                 $old = array_pop($ret);
116 116
                 array_push($ret, array('$or'=>array($old, $this->children[++$i]->to_mongo_filter())));
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                 array_push($ret, $this->children[$i]->to_mongo_filter());
121 121
             }
122 122
         }
123
-        if(count($ret) == 1 && is_array($ret[0]))
123
+        if (count($ret) == 1 && is_array($ret[0]))
124 124
         {
125 125
             //print_r(json_encode($ret[0])); die();
126 126
             return $ret[0];
@@ -131,27 +131,27 @@  discard block
 block discarded – undo
131 131
     function filter_array(&$array)
132 132
     {
133 133
         $res = array();
134
-        if(is_array($array))
134
+        if (is_array($array))
135 135
         {
136 136
             $search = $array;
137 137
             $count = count($this->children);
138
-            for($i = 0; $i < $count; $i++)
138
+            for ($i = 0; $i < $count; $i++)
139 139
             {
140
-                if($this->children[$i] === 'and')
140
+                if ($this->children[$i] === 'and')
141 141
                 {
142 142
                     $search = $res;
143 143
                 }
144
-                else if($this->children[$i] === 'or')
144
+                else if ($this->children[$i] === 'or')
145 145
                 {
146 146
                     $search = $array;
147 147
                 }
148 148
                 else
149 149
                 {
150
-                    foreach($search as $subarray)
150
+                    foreach ($search as $subarray)
151 151
                     {
152
-                        if(isset($subarray[$this->children[$i]->var1]))
152
+                        if (isset($subarray[$this->children[$i]->var1]))
153 153
                         {
154
-                            if($this->children[$i]->php_compare($subarray[$this->children[$i]->var1]))
154
+                            if ($this->children[$i]->php_compare($subarray[$this->children[$i]->var1]))
155 155
                             {
156 156
                                 array_push($res, $subarray);
157 157
                             }
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
     public function getClause($substr)
172 172
     {
173 173
         $count = count($this->children);
174
-        for($i = 0; $i < $count; $i++)
174
+        for ($i = 0; $i < $count; $i++)
175 175
         {
176
-            if(!is_object($this->children[$i])) continue;
177
-            if(strstr($this->children[$i]->var1, $substr) !== false ||
176
+            if (!is_object($this->children[$i])) continue;
177
+            if (strstr($this->children[$i]->var1, $substr) !== false ||
178 178
                strstr($this->children[$i]->var2, $substr) !== false)
179 179
             {
180 180
                 return $this->children[$i];
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 
185 185
     public function addToSQLString($string)
186 186
     {
187
-        $this->sqlAppend.=$string;
187
+        $this->sqlAppend .= $string;
188 188
     }
189 189
 
190 190
     public function appendChild($child)
191 191
     {
192
-        if($child === 'and' || $child === 'or')
192
+        if ($child === 'and' || $child === 'or')
193 193
         {
194 194
             array_push($this->children, $child);
195 195
             return;
196 196
         }
197
-        else if(is_a($child, '\Data\Filter'))
197
+        else if (is_a($child, '\Data\Filter'))
198 198
         {
199 199
             $this->children = array_merge($this->children, $child->children);
200 200
         }
Please login to merge, or discard this patch.
Braces   +20 added lines, -25 removed lines patch added patch discarded remove patch
@@ -30,11 +30,15 @@  discard block
 block discarded – undo
30 30
             return array(new FilterClause($string));
31 31
         }
32 32
         $children = array();
33
-        if($parens) array_push($children, '(');
33
+        if($parens) {
34
+            array_push($children, '(');
35
+        }
34 36
         $children = array_merge($children, self::process_string($clauses[1]));
35 37
         array_push($children, trim($clauses[2]));
36 38
         $children = array_merge($children, self::process_string($clauses[3]));
37
-        if($parens) array_push($children, ')');
39
+        if($parens) {
40
+            array_push($children, ')');
41
+        }
38 42
         return $children;
39 43
     }
40 44
 
@@ -47,16 +51,13 @@  discard block
 block discarded – undo
47 51
             if($this->children[$i] === '(' || $this->children[$i] === ')')
48 52
             {
49 53
                 $ret.=$this->children[$i];
50
-            }
51
-            else if($this->children[$i] === 'and')
54
+            } else if($this->children[$i] === 'and')
52 55
             {
53 56
                 $ret.=' AND ';
54
-            }
55
-            else if($this->children[$i] === 'or')
57
+            } else if($this->children[$i] === 'or')
56 58
             {
57 59
                 $ret.=' OR ';
58
-            }
59
-            else
60
+            } else
60 61
             {
61 62
                 $ret.=$this->children[$i]->to_sql_string();
62 63
             }
@@ -78,16 +79,14 @@  discard block
 block discarded – undo
78 79
                     throw new \Exception('Do not support both and or');
79 80
                 }
80 81
                 $prefix = '&';
81
-            }
82
-            else if($this->children[$i] === 'or')
82
+            } else if($this->children[$i] === 'or')
83 83
             {
84 84
                 if($prefix == '&')
85 85
                 {
86 86
                     throw new \Exception('Do not support both and or');
87 87
                 }
88 88
                 $prefix = '|';
89
-            }
90
-            else
89
+            } else
91 90
             {
92 91
                 $ret.=$this->children[$i]->to_ldap_string();
93 92
             }
@@ -109,13 +108,11 @@  discard block
 block discarded – undo
109 108
             {
110 109
                 $old = array_pop($ret);
111 110
                 array_push($ret, array('$and'=>array($old, $this->children[++$i]->to_mongo_filter())));
112
-            }
113
-            else if($this->children[$i] === 'or')
111
+            } else if($this->children[$i] === 'or')
114 112
             {
115 113
                 $old = array_pop($ret);
116 114
                 array_push($ret, array('$or'=>array($old, $this->children[++$i]->to_mongo_filter())));
117
-            }
118
-            else
115
+            } else
119 116
             {
120 117
                 array_push($ret, $this->children[$i]->to_mongo_filter());
121 118
             }
@@ -140,12 +137,10 @@  discard block
 block discarded – undo
140 137
                 if($this->children[$i] === 'and')
141 138
                 {
142 139
                     $search = $res;
143
-                }
144
-                else if($this->children[$i] === 'or')
140
+                } else if($this->children[$i] === 'or')
145 141
                 {
146 142
                     $search = $array;
147
-                }
148
-                else
143
+                } else
149 144
                 {
150 145
                     foreach($search as $subarray)
151 146
                     {
@@ -173,7 +168,9 @@  discard block
 block discarded – undo
173 168
         $count = count($this->children);
174 169
         for($i = 0; $i < $count; $i++)
175 170
         {
176
-            if(!is_object($this->children[$i])) continue;
171
+            if(!is_object($this->children[$i])) {
172
+                continue;
173
+            }
177 174
             if(strstr($this->children[$i]->var1, $substr) !== false ||
178 175
                strstr($this->children[$i]->var2, $substr) !== false)
179 176
             {
@@ -193,12 +190,10 @@  discard block
 block discarded – undo
193 190
         {
194 191
             array_push($this->children, $child);
195 192
             return;
196
-        }
197
-        else if(is_a($child, '\Data\Filter'))
193
+        } else if(is_a($child, '\Data\Filter'))
198 194
         {
199 195
             $this->children = array_merge($this->children, $child->children);
200
-        }
201
-        else
196
+        } else
202 197
         {
203 198
             $this->children = array_merge($this->children, self::process_string($child));
204 199
         }
Please login to merge, or discard this patch.
Data/class.MongoDataTable.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@  discard block
 block discarded – undo
6 6
     protected $collection;
7 7
     protected $namespace;
8 8
 
9
-    function __construct($collection, $collection_name=false)
9
+    function __construct($collection, $collection_name = false)
10 10
     {
11
-        if($collection_name !== false)
11
+        if ($collection_name !== false)
12 12
         {
13 13
             $this->namespace = $collection.'.'.$collection_name;
14 14
         }
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
         }
19 19
     }
20 20
 
21
-    function count($filter=false)
21
+    function count($filter = false)
22 22
     {
23 23
         $criteria = array();
24
-        if($filter !== false)
24
+        if ($filter !== false)
25 25
         {
26
-            if($filter instanceof \Data\Filter)
26
+            if ($filter instanceof \Data\Filter)
27 27
             {
28 28
                 $criteria = $filter->to_mongo_filter();
29 29
             }
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
         return $this->collection->count($criteria);
36 36
     }
37 37
 
38
-    function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false)
38
+    function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false)
39 39
     {
40 40
         $fields   = array();
41 41
         $criteria = array();
42
-        if($filter !== false)
42
+        if ($filter !== false)
43 43
         {
44
-            if(is_array($filter))
44
+            if (is_array($filter))
45 45
             {
46 46
                 $criteria = $filter;
47 47
             }
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
                 $criteria = $filter->to_mongo_filter();
51 51
             }
52 52
         }
53
-        if($select !== false)
53
+        if ($select !== false)
54 54
         {
55 55
             $fields = array_fill_keys($select, 1);
56 56
         }
57
-        $cursor   = $this->collection->find($criteria, $fields);
58
-        if($params !== false && isset($params['fields']))
57
+        $cursor = $this->collection->find($criteria, $fields);
58
+        if ($params !== false && isset($params['fields']))
59 59
         {
60 60
             $cursor->fields($params['fields']);
61 61
         }
62
-        if($sort  !== false)
62
+        if ($sort !== false)
63 63
         {
64 64
             $cursor->sort($sort);
65 65
         }
66
-        if($skip  !== false)
66
+        if ($skip !== false)
67 67
         {
68 68
             $cursor->skip($skip);
69 69
         }
70
-        if($count !== false)
70
+        if ($count !== false)
71 71
         {
72 72
             $cursor->limit($count);
73 73
         }
74
-        $ret      = array();
75
-        foreach($cursor as $doc)
74
+        $ret = array();
75
+        foreach ($cursor as $doc)
76 76
         {
77 77
             array_push($ret, $doc);
78 78
         }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     function create($data)
83 83
     {
84 84
         $res = $this->collection->insert($data);
85
-        if($res === false || $res['err'] !== null)
85
+        if ($res === false || $res['err'] !== null)
86 86
         {
87 87
             return false;
88 88
         }
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
     function update($filter, $data)
93 93
     {
94 94
         $criteria = array();
95
-        if($filter !== false)
95
+        if ($filter !== false)
96 96
         {
97
-            if(is_array($filter))
97
+            if (is_array($filter))
98 98
             {
99 99
                 $criteria = $filter;
100 100
             }
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
                 $criteria = $filter->to_mongo_filter();
104 104
             }
105 105
         }
106
-        if(isset($data['_id']))
106
+        if (isset($data['_id']))
107 107
         {
108 108
             unset($data['_id']);
109 109
         }
110 110
         $res = $this->collection->update($criteria, array('$set' => $data));
111
-        if($res === false || $res['err'] !== null)
111
+        if ($res === false || $res['err'] !== null)
112 112
         {
113 113
             return false;
114 114
         }
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     function delete($filter)
119 119
     {
120 120
         $criteria = array();
121
-        if($filter !== false)
121
+        if ($filter !== false)
122 122
         {
123
-            if(is_array($filter))
123
+            if (is_array($filter))
124 124
             {
125 125
                 $criteria = $filter;
126 126
             }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             }
131 131
         }
132 132
         $res = $this->collection->remove($criteria);
133
-        if($res === false || $res['err'] !== null)
133
+        if ($res === false || $res['err'] !== null)
134 134
         {
135 135
             return false;
136 136
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
         if($collection_name !== false)
12 12
         {
13 13
             $this->namespace = $collection.'.'.$collection_name;
14
-        }
15
-        else
14
+        } else
16 15
         {
17 16
             $this->collection = $collection;
18 17
         }
@@ -26,8 +25,7 @@  discard block
 block discarded – undo
26 25
             if($filter instanceof \Data\Filter)
27 26
             {
28 27
                 $criteria = $filter->to_mongo_filter();
29
-            }
30
-            else
28
+            } else
31 29
             {
32 30
                 $criteria = $filter;
33 31
             }
@@ -44,8 +42,7 @@  discard block
 block discarded – undo
44 42
             if(is_array($filter))
45 43
             {
46 44
                 $criteria = $filter;
47
-            }
48
-            else
45
+            } else
49 46
             {
50 47
                 $criteria = $filter->to_mongo_filter();
51 48
             }
@@ -97,8 +94,7 @@  discard block
 block discarded – undo
97 94
             if(is_array($filter))
98 95
             {
99 96
                 $criteria = $filter;
100
-            }
101
-            else
97
+            } else
102 98
             {
103 99
                 $criteria = $filter->to_mongo_filter();
104 100
             }
@@ -123,8 +119,7 @@  discard block
 block discarded – undo
123 119
             if(is_array($filter))
124 120
             {
125 121
                 $criteria = $filter;
126
-            }
127
-            else
122
+            } else
128 123
             {
129 124
                 $criteria = $filter->to_mongo_filter();
130 125
             }
Please login to merge, or discard this patch.
Data/class.MongoDataSet.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
         $collections = $this->db->getCollectionNames();
66 66
         if(in_array($name, $collections))
67 67
         {
68
-             return true;
68
+                return true;
69 69
         }
70 70
         return false;
71 71
     }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
     {
12 12
         $namespace = substr($classname, 0, $lastNsPos);
13 13
         $classname = substr($classname, $lastNsPos + 1);
14
-        $filename  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
14
+        $filename  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR;
15 15
     }
16
-    if(strlen($namespace))
16
+    if (strlen($namespace))
17 17
     {
18
-        $namespace.=DIRECTORY_SEPARATOR;
18
+        $namespace .= DIRECTORY_SEPARATOR;
19 19
     }
20 20
     $filename = __DIR__.'/../libs/mongofill/src/'.$namespace.$classname.'.php';
21
-    if(is_readable($filename))
21
+    if (is_readable($filename))
22 22
     {
23 23
         require $filename;
24 24
     }
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
         $this->mangaer = null;
38 38
         $this->db = null;
39 39
         $this->db_name = null;
40
-        if(class_exists('MongoClient'))
40
+        if (class_exists('MongoClient'))
41 41
         {
42 42
             $this->setupMongoClient($params);
43 43
         }
44
-        else if(class_exists('\MongoDB\Driver\Manager'))
44
+        else if (class_exists('\MongoDB\Driver\Manager'))
45 45
         {
46 46
             $this->setupMongoManager($params);
47 47
         }
48 48
         else
49 49
         {
50 50
             require __DIR__.'/../libs/mongofill/src/functions.php';
51
-            if(version_compare(PHP_VERSION, '5.3.0', '>='))
51
+            if (version_compare(PHP_VERSION, '5.3.0', '>='))
52 52
             {
53 53
                 spl_autoload_register('\Data\MongofillAutoload', true, true);
54 54
             }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     function tableExists($name)
64 64
     {
65 65
         $collections = $this->db->getCollectionNames();
66
-        if(in_array($name, $collections))
66
+        if (in_array($name, $collections))
67 67
         {
68 68
              return true;
69 69
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
     function getTable($name)
74 74
     {
75
-        if($this->db !== null)
75
+        if ($this->db !== null)
76 76
         {
77 77
             return new MongoDataTable($this->db->selectCollection($name));
78 78
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
     private function setupMongoClient($params)
86 86
     {
87
-        if(isset($params['user']))
87
+        if (isset($params['user']))
88 88
         {
89 89
             $this->client = new \MongoClient('mongodb://'.$params['host'].'/'.$params['db'], array('username'=>$params['user'], 'password'=>$params['pass']));
90 90
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
     private function setupMongoManager($params)
99 99
     {
100
-        if(isset($params['user']))
100
+        if (isset($params['user']))
101 101
         {
102 102
             $this->manager = new \MongoDB\Driver\Manager('mongodb://'.$params['user'].':'.$params['pass'].'@'.$params['host'].'/'.$params['db']);
103 103
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,19 +40,16 @@  discard block
 block discarded – undo
40 40
         if(class_exists('MongoClient'))
41 41
         {
42 42
             $this->setupMongoClient($params);
43
-        }
44
-        else if(class_exists('\MongoDB\Driver\Manager'))
43
+        } else if(class_exists('\MongoDB\Driver\Manager'))
45 44
         {
46 45
             $this->setupMongoManager($params);
47
-        }
48
-        else
46
+        } else
49 47
         {
50 48
             require __DIR__.'/../libs/mongofill/src/functions.php';
51 49
             if(version_compare(PHP_VERSION, '5.3.0', '>='))
52 50
             {
53 51
                 spl_autoload_register('\Data\MongofillAutoload', true, true);
54
-            }
55
-            else
52
+            } else
56 53
             {
57 54
                 spl_autoload_register('\Data\MongofillAutoload');
58 55
             }
@@ -75,8 +72,7 @@  discard block
 block discarded – undo
75 72
         if($this->db !== null)
76 73
         {
77 74
             return new MongoDataTable($this->db->selectCollection($name));
78
-        }
79
-        else
75
+        } else
80 76
         {
81 77
             return new MongoDataTable($this->db_name, $name);
82 78
         }
@@ -87,8 +83,7 @@  discard block
 block discarded – undo
87 83
         if(isset($params['user']))
88 84
         {
89 85
             $this->client = new \MongoClient('mongodb://'.$params['host'].'/'.$params['db'], array('username'=>$params['user'], 'password'=>$params['pass']));
90
-        }
91
-        else
86
+        } else
92 87
         {
93 88
             $this->client = new \MongoClient('mongodb://'.$params['host'].'/'.$params['db']);
94 89
         }
@@ -100,8 +95,7 @@  discard block
 block discarded – undo
100 95
         if(isset($params['user']))
101 96
         {
102 97
             $this->manager = new \MongoDB\Driver\Manager('mongodb://'.$params['user'].':'.$params['pass'].'@'.$params['host'].'/'.$params['db']);
103
-        }
104
-        else
98
+        } else
105 99
         {
106 100
             $this->manager = new \MongoDB\Driver\Manager('mongodb://'.$params['host'].'/'.$params['db']);
107 101
         }
Please login to merge, or discard this patch.
class.JsonSerializable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 * @link http://www.php.net/manual/en/class.jsonserializable.php
11 11
 */
12 12
 
13
-if(PHP_VERSION_ID < 50400)
13
+if (PHP_VERSION_ID < 50400)
14 14
 {
15 15
 /**
16 16
 * JsonSerializable interface
Please login to merge, or discard this patch.