Passed
Push — master ( e9dd98...02cf1a )
by Richard
01:44
created
maphper/lib/visibilityoverride.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,12 +9,13 @@
 block discarded – undo
9 9
 		if ($object instanceof \stdclass) {
10 10
 			$this->readClosure = function() use ($object) { return $object;	};
11 11
 			$this->writeClosure = function ($field, $value) use ($object) { $object->$field = $value; };
12
-		}
13
-		else {
12
+		} else {
14 13
 			$this->readClosure = function() {
15 14
 				$data = new \stdClass;
16 15
 				foreach ($this as $k => $v)	{
17
-					if (is_scalar($v) || is_null($v) || (is_object($v) && $v instanceof \DateTime))	$data->$k = $v;
16
+					if (is_scalar($v) || is_null($v) || (is_object($v) && $v instanceof \DateTime)) {
17
+						$data->$k = $v;
18
+					}
18 19
 				}
19 20
 				return $data;
20 21
 			};
Please login to merge, or discard this patch.
maphper/Optimiser/MySql.php 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,16 +11,21 @@  discard block
 block discarded – undo
11 11
 		foreach ($columns as $column) {
12 12
 			$parts = explode('.', $column->Field_name);
13 13
 			$name = $this->quote(end($parts));
14
-			if ($column->Min_value === null && $column->Max_value === null) $this->pdo->query('ALTER TABLE ' . $this->quote($table) . ' DROP COLUMN ' . $name);
15
-			else {
14
+			if ($column->Min_value === null && $column->Max_value === null) {
15
+				$this->pdo->query('ALTER TABLE ' . $this->quote($table) . ' DROP COLUMN ' . $name);
16
+			} else {
16 17
 				$type = $column->Optimal_fieldtype;
17 18
 				if ($column->Max_length < 11) {
18 19
 					//Check for dates
19 20
 					$count = $this->pdo->query('SELECT count(*) as `count` FROM ' . $this->quote($table) . ' WHERE STR_TO_DATE(' . $name . ',\'%Y-%m-%d %H:%i:s\') IS NULL OR STR_TO_DATE(' . $name . ',\'%Y-%m-%d %H:%i:s\') != ' . $name . ' LIMIT 1')->fetch(\PDO::FETCH_OBJ)->count;
20
-					if ($count == 0) $type = 'DATETIME';
21
+					if ($count == 0) {
22
+						$type = 'DATETIME';
23
+					}
21 24
 
22 25
 					$count = $this->pdo->query('SELECT count(*) as `count` FROM ' . $this->quote($table) . ' WHERE STR_TO_DATE(' . $name . ',\'%Y-%m-%d\') IS NULL OR STR_TO_DATE(' . $name . ',\'%Y-%m-%d\') != ' . $name . ' LIMIT 1')->fetch(\PDO::FETCH_OBJ)->count;
23
-					if ($count == 0) $type = 'DATE';
26
+					if ($count == 0) {
27
+						$type = 'DATE';
28
+					}
24 29
 				}
25 30
 
26 31
 				//If it's text, work out if it would be better to be something else
@@ -30,8 +35,7 @@  discard block
 block discarded – undo
30 35
 					if ($count == 0) {
31 36
 						$type = 'INT(11)';
32 37
 						$runAgain = true;
33
-					}
34
-					else {
38
+					} else {
35 39
 						//See if it's decimal
36 40
 						$count = $this->pdo->query('SELECT count(*) FROM ' . $table . ' WHERE concat(\'\', ' . $name . ' * 1) != ' . $name . ')')->fetch(\PDO::FETCH_OBJ)->count;
37 41
 						if ($count == 0) {
@@ -45,6 +49,8 @@  discard block
 block discarded – undo
45 49
 			}
46 50
 		}
47 51
 		//Sometimes a second pass is needed, if a column has gone from varchar -> int(11) a better int type may be needed
48
-		if ($runAgain) $this->optimiseColumns($table);
52
+		if ($runAgain) {
53
+			$this->optimiseColumns($table);
54
+		}
49 55
 	}
50 56
 }
51 57
\ No newline at end of file
Please login to merge, or discard this patch.
maphper/datasource/databaseoptions.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	public function getAdapter() {
13
-		if (!($this->db instanceof \PDO)) return $this->db;
13
+		if (!($this->db instanceof \PDO)) {
14
+			return $this->db;
15
+		}
14 16
 
15 17
 		$adapter = '\\Maphper\\DataSource\\' . ucfirst($this->db->getAttribute(\PDO::ATTR_DRIVER_NAME)) . 'Adapter';
16 18
 
@@ -18,7 +20,9 @@  discard block
 block discarded – undo
18 20
 	}
19 21
 
20 22
 	public function getEditMode() {
21
-		if (!isset($this->options['editmode'])) return false;
23
+		if (!isset($this->options['editmode'])) {
24
+			return false;
25
+		}
22 26
 
23 27
 		return $this->options['editmode'] === true ? Database::EDIT_STRUCTURE | Database::EDIT_INDEX | Database::EDIT_OPTIMISE : $this->options['editmode'];
24 28
 	}
Please login to merge, or discard this patch.
maphper/datasource/mock.php 1 patch
Braces   +43 added lines, -22 removed lines patch added patch discarded remove patch
@@ -27,8 +27,12 @@  discard block
 block discarded – undo
27 27
             list($columns, $order) = explode(' ', $options['order']);
28 28
             usort($filteredArray, $this->getOrderFunction($order, $columns));
29 29
         }
30
-        if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']);
31
-        if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']);
30
+        if (isset($options['offset'])) {
31
+        	$filteredArray = array_slice($filteredArray, $options['offset']);
32
+        }
33
+        if (isset($options['limit'])) {
34
+        	$filteredArray = array_slice($filteredArray, 0, $options['limit']);
35
+        }
32 36
         return $filteredArray;
33 37
     }
34 38
 
@@ -37,8 +41,11 @@  discard block
 block discarded – undo
37 41
             foreach ($fields as $key => $val) {
38 42
                 $currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode);
39 43
 
40
-                if (Maphper::FIND_OR & $mode && $currentFieldResult === true) return true;
41
-                else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) return false;
44
+                if (Maphper::FIND_OR & $mode && $currentFieldResult === true) {
45
+                	return true;
46
+                } else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) {
47
+                	return false;
48
+                }
42 49
             }
43 50
             return !(Maphper::FIND_OR & $mode);
44 51
         };
@@ -47,12 +54,13 @@  discard block
 block discarded – undo
47 54
     private function getIfFieldMatches($key, $val, $data, $mode) {
48 55
         if (is_numeric($key) && is_array($val)) {
49 56
             return $this->getSearchFieldFunction($val, $key)($data);
57
+        } else if (!isset($data->$key)) {
58
+        	return false;
59
+        } else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val)) {
60
+                    return in_array($data->$key, $val);
61
+        } else {
62
+                    return $this->processFilter($mode, $val, $data->$key);
50 63
         }
51
-        else if (!isset($data->$key)) return false;
52
-        else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val))
53
-            return in_array($data->$key, $val);
54
-        else
55
-            return $this->processFilter($mode, $val, $data->$key);
56 64
     }
57 65
 
58 66
   	public function findAggregate($function, $field, $group = null, array $criteria = [], array $options = []) {
@@ -64,14 +72,15 @@  discard block
 block discarded – undo
64 72
     }
65 73
 
66 74
   	public function deleteByField(array $fields, array $options) {
67
-        foreach ($this->findByField($fields, $options) as $val) unset($this->data[$val->{$this->id[0]}]);
75
+        foreach ($this->findByField($fields, $options) as $val) {
76
+        	unset($this->data[$val->{$this->id[0]}]);
77
+        }
68 78
     }
69 79
 
70 80
     public function save($data) {
71 81
         if (isset($data->{$this->id[0]})) {
72 82
             $id = $data->{$this->id[0]};
73
-        }
74
-        else {
83
+        } else {
75 84
             $id = count($this->data);
76 85
             $data->{$this->id[0]} = $id;
77 86
         }
@@ -91,23 +100,35 @@  discard block
 block discarded – undo
91 100
             if ($aColumn === $bColumn) {
92 101
               $sortVal = 0;
93 102
               continue;
103
+            } else {
104
+            	$sortVal = ($aColumn < $bColumn) ? -1 : 1;
94 105
             }
95
-            else $sortVal = ($aColumn < $bColumn) ? -1 : 1;
96 106
             break;
97 107
           }
98
-          if ($order === 'desc') return -$sortVal;
99
-          else return $sortVal;
108
+          if ($order === 'desc') {
109
+          	return -$sortVal;
110
+          } else {
111
+          	return $sortVal;
112
+          }
100 113
         };
101 114
     }
102 115
 
103 116
     private function processFilter($mode, $expected, $actual) {
104
-        if (Maphper::FIND_NOT & $mode) return $expected != $actual;
105
-        else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) return $expected <= $actual;
106
-        else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) return $expected >= $actual;
107
-        else if (Maphper::FIND_GREATER & $mode) return $expected < $actual;
108
-        else if (Maphper::FIND_LESS & $mode) return $expected > $actual;
109
-        else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1];
110
-        else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual);
117
+        if (Maphper::FIND_NOT & $mode) {
118
+        	return $expected != $actual;
119
+        } else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) {
120
+        	return $expected <= $actual;
121
+        } else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) {
122
+        	return $expected >= $actual;
123
+        } else if (Maphper::FIND_GREATER & $mode) {
124
+        	return $expected < $actual;
125
+        } else if (Maphper::FIND_LESS & $mode) {
126
+        	return $expected > $actual;
127
+        } else if (Maphper::FIND_BETWEEN & $mode) {
128
+        	return $expected[0] <= $actual && $actual <= $expected[1];
129
+        } else if (Maphper::FIND_NOCASE & $mode) {
130
+        	return strtolower($expected) == strtolower($actual);
131
+        }
111 132
         return $expected == $actual;
112 133
     }
113 134
 }
Please login to merge, or discard this patch.
maphper/datasource/StmtCache.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@
 block discarded – undo
10 10
 
11 11
     public function getCachedStmt($sql) {
12 12
 		$queryId = $this->getQueryId($sql);
13
-		if (isset($this->queryCache[$queryId])) $stmt = $this->queryCache[$queryId];
14
-		else {
13
+		if (isset($this->queryCache[$queryId])) {
14
+			$stmt = $this->queryCache[$queryId];
15
+		} else {
15 16
 			$stmt = $this->pdo->prepare($sql, [\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY]);
16
-			if ($stmt) $this->queryCache[$queryId] = $stmt;
17
+			if ($stmt) {
18
+				$this->queryCache[$queryId] = $stmt;
19
+			}
17 20
 		}
18 21
 		return $stmt;
19 22
 	}
Please login to merge, or discard this patch.
maphper/datasource/mysqladapter.php 1 patch
Braces   +27 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,10 +24,15 @@  discard block
 block discarded – undo
24 24
 	}
25 25
 
26 26
 	private function getType($val) {
27
-		if ($val instanceof \DateTime) return 'DATETIME';
28
-		else if (is_int($val)) return  'INT(11)';
29
-		else if (is_double($val)) return 'DECIMAL(9,' . strlen($val) - strrpos($val, '.') - 1 . ')';
30
-		else if (is_string($val)) return strlen($val) < 192 ? 'VARCHAR(191)' : 'LONGBLOB';
27
+		if ($val instanceof \DateTime) {
28
+			return 'DATETIME';
29
+		} else if (is_int($val)) {
30
+			return  'INT(11)';
31
+		} else if (is_double($val)) {
32
+			return 'DECIMAL(9,' . strlen($val) - strrpos($val, '.') - 1 . ')';
33
+		} else if (is_string($val)) {
34
+			return strlen($val) < 192 ? 'VARCHAR(191)' : 'LONGBLOB';
35
+		}
31 36
 		return 'VARCHAR(191)';
32 37
 	}
33 38
 
@@ -36,8 +41,11 @@  discard block
 block discarded – undo
36 41
 		$parts = [];
37 42
 		foreach ($primaryKey as $key) {
38 43
 			$pk = $data->$key;
39
-			if ($pk == null) $parts[] = $key . ' INT(11) NOT NULL AUTO_INCREMENT';
40
-			else $parts[] = $key . ' ' . $this->getType($pk) . ' NOT NULL';
44
+			if ($pk == null) {
45
+				$parts[] = $key . ' INT(11) NOT NULL AUTO_INCREMENT';
46
+			} else {
47
+				$parts[] = $key . ' ' . $this->getType($pk) . ' NOT NULL';
48
+			}
41 49
 		}
42 50
 
43 51
 		$pkField = implode(', ', $parts) . ', PRIMARY KEY(' . implode(', ', $primaryKey) . ')';
@@ -48,15 +56,20 @@  discard block
 block discarded – undo
48 56
 		$this->createTable($table, $primaryKey, $data);
49 57
 
50 58
 		foreach ($data as $key => $value) {
51
-			if (is_array($value) || (is_object($value) && !($value instanceof \DateTime))) continue;
52
-			if (in_array($key, $primaryKey)) continue;
59
+			if (is_array($value) || (is_object($value) && !($value instanceof \DateTime))) {
60
+				continue;
61
+			}
62
+			if (in_array($key, $primaryKey)) {
63
+				continue;
64
+			}
53 65
 
54 66
 			$type = $this->getType($value);
55 67
 
56 68
 			try {
57
-				if (!$this->pdo->query('ALTER TABLE ' . $table . ' ADD ' . $this->quote($key) . ' ' . $type)) throw new \Exception('Could not alter table');
58
-			}
59
-			catch (\Exception $e) {
69
+				if (!$this->pdo->query('ALTER TABLE ' . $table . ' ADD ' . $this->quote($key) . ' ' . $type)) {
70
+					throw new \Exception('Could not alter table');
71
+				}
72
+			} catch (\Exception $e) {
60 73
 				$this->pdo->query('ALTER TABLE ' . $table . ' MODIFY ' . $this->quote($key) . ' ' . $type);
61 74
 			}
62 75
 		}
@@ -74,7 +87,9 @@  discard block
 block discarded – undo
74 87
 		$keyName = $this->quote(implode('_', $fields));
75 88
 
76 89
 		$results = $this->pdo->query('SHOW INDEX FROM ' . $this->quote($table) . ' WHERE Key_Name = "' . $keyName . '"');
77
-		if ($results && count($results->fetchAll()) == 0)  $this->pdo->query('CREATE INDEX ' . $keyName . ' ON ' . $this->quote($table) . ' (' . implode(', ', $fields) . ')');
90
+		if ($results && count($results->fetchAll()) == 0) {
91
+			$this->pdo->query('CREATE INDEX ' . $keyName . ' ON ' . $this->quote($table) . ' (' . implode(', ', $fields) . ')');
92
+		}
78 93
 	}
79 94
 
80 95
 	public function optimiseColumns($table) {
Please login to merge, or discard this patch.
maphper/datasource/sqliteadapter.php 1 patch
Braces   +35 added lines, -17 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 		$args = $query->getArgs();
20 20
 
21 21
         //Handle SQLite when PDO_ERRMODE is set to SILENT
22
-        if ($stmt === false) throw new \Exception('Invalid query');
22
+        if ($stmt === false) {
23
+        	throw new \Exception('Invalid query');
24
+        }
23 25
 
24 26
         $stmt->execute($args);
25 27
         if ($stmt->errorCode() !== '00000' && $stmt->errorInfo()[2] == 'database schema has changed') {
@@ -35,12 +37,19 @@  discard block
 block discarded – undo
35 37
 	}
36 38
 	
37 39
 	private function getType($val) {
38
-		if ($val instanceof \DateTime) return 'DATETIME';
39
-		else if (is_int($val)) return  'INTEGER';
40
-		else if (is_double($val)) return 'DECIMAL(9,' . strlen($val) - strrpos($val, '.') - 1 . ')';
41
-		else if (is_string($val) && strlen($val) < 256) return 'VARCHAR(255)';
42
-		else if (is_string($val) && strlen($val) > 256) return 'LONGBLOG';
43
-		else return 'VARCHAR(255)';		
40
+		if ($val instanceof \DateTime) {
41
+			return 'DATETIME';
42
+		} else if (is_int($val)) {
43
+			return  'INTEGER';
44
+		} else if (is_double($val)) {
45
+			return 'DECIMAL(9,' . strlen($val) - strrpos($val, '.') - 1 . ')';
46
+		} else if (is_string($val) && strlen($val) < 256) {
47
+			return 'VARCHAR(255)';
48
+		} else if (is_string($val) && strlen($val) > 256) {
49
+			return 'LONGBLOG';
50
+		} else {
51
+			return 'VARCHAR(255)';
52
+		}
44 53
 	}
45 54
 
46 55
 	private function tableExists($name) {
@@ -74,8 +83,7 @@  discard block
 block discarded – undo
74 83
 				$this->pdo->query('INSERT INTO ' . $this->quote($table . $affix) . '(' . $columns . ') SELECT ' . $columns . ' FROM ' . $this->quote($table));
75 84
 				$this->pdo->query('DROP TABLE IF EXISTS ' . $table );
76 85
 			}
77
-		}
78
-		catch (\PDOException $e) {
86
+		} catch (\PDOException $e) {
79 87
 			// No data to copy
80 88
 			echo $e->getMessage();
81 89
 		}
@@ -89,8 +97,11 @@  discard block
 block discarded – undo
89 97
 		$parts = [];
90 98
 		foreach ($primaryKey as $key) {
91 99
 			$pk = $data->$key;
92
-			if ($pk == null) $parts[] = $key . ' INTEGER'; 
93
-			else $parts[] = $key . ' ' . $this->getType($pk) . ' NOT NULL';					
100
+			if ($pk == null) {
101
+				$parts[] = $key . ' INTEGER';
102
+			} else {
103
+				$parts[] = $key . ' ' . $this->getType($pk) . ' NOT NULL';
104
+			}
94 105
 		}
95 106
 		
96 107
 		$pkField = implode(', ', $parts) . ', PRIMARY KEY(' . implode(', ', $primaryKey) . ')';
@@ -99,8 +110,12 @@  discard block
 block discarded – undo
99 110
 		$this->pdo->query('CREATE TABLE ' . $table . ' (' . $pkField . ')');
100 111
 					
101 112
 		foreach ($data as $key => $value) {
102
-			if (is_array($value) || (is_object($value) && !($value instanceof \DateTime))) continue;
103
-			if (in_array($key, $primaryKey)) continue;
113
+			if (is_array($value) || (is_object($value) && !($value instanceof \DateTime))) {
114
+				continue;
115
+			}
116
+			if (in_array($key, $primaryKey)) {
117
+				continue;
118
+			}
104 119
 
105 120
 			$type = $this->getType($value);
106 121
 		
@@ -110,10 +125,14 @@  discard block
 block discarded – undo
110 125
 	
111 126
 
112 127
 	public function addIndex($table, array $fields) {
113
-		if (empty($fields)) return false;
128
+		if (empty($fields)) {
129
+			return false;
130
+		}
114 131
 		
115 132
 		//SQLite doesn't support ASC/DESC indexes, remove the keywords
116
-		foreach ($fields as &$field) $field = str_ireplace([' desc', ' asc'], '', $field);
133
+		foreach ($fields as &$field) {
134
+			$field = str_ireplace([' desc', ' asc'], '', $field);
135
+		}
117 136
 		sort($fields);
118 137
 		$fields = array_map('strtolower', $fields);
119 138
 		$fields = array_map('trim', $fields);
@@ -122,8 +141,7 @@  discard block
 block discarded – undo
122 141
 		
123 142
 		try {
124 143
 			$this->pdo->query('CREATE INDEX IF NOT EXISTS  ' . $keyName . ' ON ' . $table . ' (' . implode(', ', $fields) . ')');
125
-		}
126
-		catch (\Exception $e) {
144
+		} catch (\Exception $e) {
127 145
 			
128 146
 		}
129 147
 	}
Please login to merge, or discard this patch.
maphper/lib/selectbuilder.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,17 +7,23 @@
 block discarded – undo
7 7
 
8 8
 		if (isset($options['offset'])) {
9 9
 			$offset = ' OFFSET ' . $options['offset'];
10
-			if (!$limit) $limit = ' LIMIT  1000';
10
+			if (!$limit) {
11
+				$limit = ' LIMIT  1000';
12
+			}
13
+		} else {
14
+			$offset = '';
11 15
 		}
12
-		else $offset = '';
13 16
 
14 17
 		$order = isset($options['order']) ? ' ORDER BY ' . $options['order'] : '';
15 18
 		return new Query('SELECT * FROM ' . $table . ' ' . $where . $order . $limit . $offset, $args);
16 19
 	}
17 20
 
18 21
 	public function aggregate($table, $function, $field, $where, $args, $group) {
19
-		if ($group == true) $groupBy = ' GROUP BY ' . $field;
20
-		else $groupBy = '';
22
+		if ($group == true) {
23
+			$groupBy = ' GROUP BY ' . $field;
24
+		} else {
25
+			$groupBy = '';
26
+		}
21 27
 		return new Query('SELECT ' . $function . '(' . $field . ') as val, ' . $field . '   FROM ' . $table . ($where != null ? ' WHERE ' . $where : '') . ' ' . $groupBy, $args);
22 28
 	}
23 29
 }
Please login to merge, or discard this patch.
maphper/lib/Sql/WhereBuilder.php 1 patch
Braces   +51 added lines, -28 removed lines patch added patch discarded remove patch
@@ -9,71 +9,94 @@
 block discarded – undo
9 9
 
10 10
 		foreach ($fields as $key => $value) {
11 11
             if ($value instanceof \DateTime) {
12
-    			if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
13
-    			else $value = $value->format('Y-m-d H:i:s');
12
+    			if ($value->format('H:i:s')  == '00:00:00') {
13
+    				$value = $value->format('Y-m-d');
14
+    			} else {
15
+    				$value = $value->format('Y-m-d H:i:s');
16
+    			}
14 17
     		}
15 18
 
16
-            if (is_object($value)) continue;
19
+            if (is_object($value)) {
20
+            	continue;
21
+            }
17 22
 			if (is_numeric($key) && is_array($value)) {
18 23
 				$result = $this->createSql($value, $key);
19
-				foreach ($result['args'] as $arg_key => $arg) $args[$arg_key] = $arg;
20
-				foreach ($result['sql'] as $arg) $sql[] = $arg;
21
-			}
22
-			else if (\Maphper\Maphper::FIND_BETWEEN & $mode) {
24
+				foreach ($result['args'] as $arg_key => $arg) {
25
+					$args[$arg_key] = $arg;
26
+				}
27
+				foreach ($result['sql'] as $arg) {
28
+					$sql[] = $arg;
29
+				}
30
+			} else if (\Maphper\Maphper::FIND_BETWEEN & $mode) {
23 31
 				$sql[] = $key . '>= :' . $key . 'from';
24 32
 				$sql[] = $key . ' <= :' . $key . 'to';
25 33
 
26 34
 				$args[$key . 'from'] = $value[0];
27 35
 				$args[$key . 'to'] = $value[1];
28
-			}
29
-			else if (!is_numeric($key) && is_array($value)) {
36
+			} else if (!is_numeric($key) && is_array($value)) {
30 37
 				$inSql = [];
31 38
 				$count = count($value);
32 39
 				for ($i = 0; $i < $count; $i++) {
33 40
 					$args[$key . $i] = $value[$i];
34 41
 					$inSql[] = ':' . $key . $i;
35 42
 				}
36
-				if (count($inSql) == 0) return [];
37
-				else $sql[] = $key . ' IN ( ' .  implode(', ', $inSql) . ')';
38
-			}
39
-			else if ($value === NULL) {
43
+				if (count($inSql) == 0) {
44
+					return [];
45
+				} else {
46
+					$sql[] = $key . ' IN ( ' .  implode(', ', $inSql) . ')';
47
+				}
48
+			} else if ($value === NULL) {
40 49
 				$nullSql = $key . ' IS ';
41
-				if (\Maphper\Maphper::FIND_NOT & $mode) $nullSql .= 'NOT ';
50
+				if (\Maphper\Maphper::FIND_NOT & $mode) {
51
+					$nullSql .= 'NOT ';
52
+				}
42 53
 				$sql[] = $nullSql . 'NULL';
43
-			}
44
-			else {
54
+			} else {
45 55
 
46 56
 				if (\Maphper\Maphper::FIND_LIKE & $mode) {
47 57
 					$operator = 'LIKE';
48 58
 					$value = '%' . $value . '%';
49
-				}
50
-				else if (\Maphper\Maphper::FIND_STARTS & $mode) {
59
+				} else if (\Maphper\Maphper::FIND_STARTS & $mode) {
51 60
 					$operator = 'LIKE';
52 61
 					$value = $value . '%';
62
+				} else {
63
+					$operator = $this->getOperator($mode);
53 64
 				}
54
-				else $operator = $this->getOperator($mode);
55 65
 
56 66
 				$args[$key] = $value;
57 67
 				$sql[] = $key . ' ' . $operator . ' :' . $key;
58 68
 			}
59 69
 		}
60 70
 
61
-		if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
62
-		else $query = implode(' AND ', $sql);
63
-		if (!empty($query)) $query = '(' . $query . ')';
71
+		if (\Maphper\Maphper::FIND_OR & $mode) {
72
+			$query = implode(' OR  ', $sql);
73
+		} else {
74
+			$query = implode(' AND ', $sql);
75
+		}
76
+		if (!empty($query)) {
77
+			$query = '(' . $query . ')';
78
+		}
64 79
 		return ['args' => $args, 'sql' => $query];
65 80
 	}
66 81
 
67 82
     private function getOperator($mode) {
68 83
         $operator = "";
69 84
 
70
-        if (\Maphper\Maphper::FIND_NOCASE & $mode) $operator = 'LIKE';
71
-        else if (\Maphper\Maphper::FIND_BIT & $mode) $operator = '&';
72
-        else if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>';
73
-        else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<';
74
-        else if (\Maphper\Maphper::FIND_NOT & $mode) $operator = '!=';
85
+        if (\Maphper\Maphper::FIND_NOCASE & $mode) {
86
+        	$operator = 'LIKE';
87
+        } else if (\Maphper\Maphper::FIND_BIT & $mode) {
88
+        	$operator = '&';
89
+        } else if (\Maphper\Maphper::FIND_GREATER & $mode) {
90
+        	$operator = '>';
91
+        } else if (\Maphper\Maphper::FIND_LESS & $mode) {
92
+        	$operator = '<';
93
+        } else if (\Maphper\Maphper::FIND_NOT & $mode) {
94
+        	$operator = '!=';
95
+        }
75 96
 
76
-        if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '=';
97
+        if (\Maphper\Maphper::FIND_EXACT & $mode) {
98
+        	$operator .= '=';
99
+        }
77 100
 
78 101
         return $operator;
79 102
     }
Please login to merge, or discard this patch.