Passed
Push — master ( 71d24f...562277 )
by Richard
01:37
created
maphper/datasource/DatabaseModify.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 namespace Maphper\DataSource;
3 3
 
4 4
 class DatabaseModify {
5
-    private $adapter;
6
-    private $alterDb;
7
-    private $table;
5
+	private $adapter;
6
+	private $alterDb;
7
+	private $table;
8 8
 
9
-    public function __construct(DatabaseAdapter $adapter, $alterDb, $table) {
10
-        $this->adapter = $adapter;
11
-        $this->alterDb = $alterDb;
12
-        $this->table = $table;
13
-    }
9
+	public function __construct(DatabaseAdapter $adapter, $alterDb, $table) {
10
+		$this->adapter = $adapter;
11
+		$this->alterDb = $alterDb;
12
+		$this->table = $table;
13
+	}
14 14
 
15
-    public function addIndex($args) {
15
+	public function addIndex($args) {
16 16
 		if (Database::EDIT_INDEX & $this->alterDb) $this->adapter->addIndex($this->table, $args);
17 17
 	}
18 18
 
19
-    public function optimizeColumns() {
20
-        if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0,500) == 1) $this->adapter->optimiseColumns($this->table);
21
-    }
19
+	public function optimizeColumns() {
20
+		if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0,500) == 1) $this->adapter->optimiseColumns($this->table);
21
+	}
22 22
 
23
-    public function getTryInsertAgain($tryagain) {
24
-        return $tryagain && Database::EDIT_STRUCTURE & $this->alterDb;
25
-    }
23
+	public function getTryInsertAgain($tryagain) {
24
+		return $tryagain && Database::EDIT_STRUCTURE & $this->alterDb;
25
+	}
26 26
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 	}
18 18
 
19 19
     public function optimizeColumns() {
20
-        if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0,500) == 1) $this->adapter->optimiseColumns($this->table);
20
+        if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0, 500) == 1) $this->adapter->optimiseColumns($this->table);
21 21
     }
22 22
 
23 23
     public function getTryInsertAgain($tryagain) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,11 +13,15 @@
 block discarded – undo
13 13
     }
14 14
 
15 15
     public function addIndex($args) {
16
-		if (Database::EDIT_INDEX & $this->alterDb) $this->adapter->addIndex($this->table, $args);
16
+		if (Database::EDIT_INDEX & $this->alterDb) {
17
+			$this->adapter->addIndex($this->table, $args);
18
+		}
17 19
 	}
18 20
 
19 21
     public function optimizeColumns() {
20
-        if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0,500) == 1) $this->adapter->optimiseColumns($this->table);
22
+        if (Database::EDIT_OPTIMISE & $this->alterDb && rand(0,500) == 1) {
23
+        	$this->adapter->optimiseColumns($this->table);
24
+        }
21 25
     }
22 26
 
23 27
     public function getTryInsertAgain($tryagain) {
Please login to merge, or discard this patch.
maphper/lib/ArrayFilter.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -3,50 +3,50 @@
 block discarded – undo
3 3
 use Maphper\Maphper;
4 4
 
5 5
 class ArrayFilter {
6
-    private $array;
6
+	private $array;
7 7
 
8
-    public function __construct(array $array) {
9
-        $this->array = $array;
10
-    }
8
+	public function __construct(array $array) {
9
+		$this->array = $array;
10
+	}
11 11
 
12
-    public function filter($fields) {
13
-        $filteredArray = array_filter($this->array, $this->getSearchFieldFunction($fields, \Maphper\Maphper::FIND_EXACT | \Maphper\Maphper::FIND_AND));
14
-        // Need to reset indexes
15
-        $filteredArray = array_values($filteredArray);
16
-        return $filteredArray;
17
-    }
12
+	public function filter($fields) {
13
+		$filteredArray = array_filter($this->array, $this->getSearchFieldFunction($fields, \Maphper\Maphper::FIND_EXACT | \Maphper\Maphper::FIND_AND));
14
+		// Need to reset indexes
15
+		$filteredArray = array_values($filteredArray);
16
+		return $filteredArray;
17
+	}
18 18
 
19
-    private function getSearchFieldFunction($fields, $mode) {
20
-        return function ($data) use ($fields, $mode) {
21
-            foreach ($fields as $key => $val) {
22
-                $currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode);
19
+	private function getSearchFieldFunction($fields, $mode) {
20
+		return function ($data) use ($fields, $mode) {
21
+			foreach ($fields as $key => $val) {
22
+				$currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode);
23 23
 
24
-                if (Maphper::FIND_OR & $mode && $currentFieldResult === true) return true;
25
-                else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) return false;
26
-            }
27
-            return !(Maphper::FIND_OR & $mode);
28
-        };
29
-    }
24
+				if (Maphper::FIND_OR & $mode && $currentFieldResult === true) return true;
25
+				else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) return false;
26
+			}
27
+			return !(Maphper::FIND_OR & $mode);
28
+		};
29
+	}
30 30
 
31
-    private function getIfFieldMatches($key, $val, $data, $mode) {
32
-        if (is_numeric($key) && is_array($val)) {
33
-            return $this->getSearchFieldFunction($val, $key)($data);
34
-        }
35
-        else if (!isset($data->$key)) return false;
36
-        else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val))
37
-            return in_array($data->$key, $val);
38
-        else
39
-            return $this->processFilter($mode, $val, $data->$key);
40
-    }
31
+	private function getIfFieldMatches($key, $val, $data, $mode) {
32
+		if (is_numeric($key) && is_array($val)) {
33
+			return $this->getSearchFieldFunction($val, $key)($data);
34
+		}
35
+		else if (!isset($data->$key)) return false;
36
+		else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val))
37
+			return in_array($data->$key, $val);
38
+		else
39
+			return $this->processFilter($mode, $val, $data->$key);
40
+	}
41 41
 
42
-    private function processFilter($mode, $expected, $actual) {
43
-        if (Maphper::FIND_NOT & $mode) return $expected != $actual;
44
-        else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) return $expected <= $actual;
45
-        else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) return $expected >= $actual;
46
-        else if (Maphper::FIND_GREATER & $mode) return $expected < $actual;
47
-        else if (Maphper::FIND_LESS & $mode) return $expected > $actual;
48
-        else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1];
49
-        else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual);
50
-        return $expected == $actual;
51
-    }
42
+	private function processFilter($mode, $expected, $actual) {
43
+		if (Maphper::FIND_NOT & $mode) return $expected != $actual;
44
+		else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) return $expected <= $actual;
45
+		else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) return $expected >= $actual;
46
+		else if (Maphper::FIND_GREATER & $mode) return $expected < $actual;
47
+		else if (Maphper::FIND_LESS & $mode) return $expected > $actual;
48
+		else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1];
49
+		else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual);
50
+		return $expected == $actual;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     }
34 34
 
35 35
     private function getSearchFieldFunction($fields, $mode) {
36
-        return function ($data) use ($fields, $mode) {
36
+        return function($data) use ($fields, $mode) {
37 37
             foreach ($fields as $key => $val) {
38 38
                 $currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode);
39 39
 
Please login to merge, or discard this patch.
Braces   +26 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,8 +21,11 @@  discard block
 block discarded – undo
21 21
             foreach ($fields as $key => $val) {
22 22
                 $currentFieldResult = $this->getIfFieldMatches($key, $val, $data, $mode);
23 23
 
24
-                if (Maphper::FIND_OR & $mode && $currentFieldResult === true) return true;
25
-                else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) return false;
24
+                if (Maphper::FIND_OR & $mode && $currentFieldResult === true) {
25
+                	return true;
26
+                } else if (!(Maphper::FIND_OR & $mode) && $currentFieldResult === false) {
27
+                	return false;
28
+                }
26 29
             }
27 30
             return !(Maphper::FIND_OR & $mode);
28 31
         };
@@ -31,22 +34,31 @@  discard block
 block discarded – undo
31 34
     private function getIfFieldMatches($key, $val, $data, $mode) {
32 35
         if (is_numeric($key) && is_array($val)) {
33 36
             return $this->getSearchFieldFunction($val, $key)($data);
37
+        } else if (!isset($data->$key)) {
38
+        	return false;
39
+        } else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val)) {
40
+                    return in_array($data->$key, $val);
41
+        } else {
42
+                    return $this->processFilter($mode, $val, $data->$key);
34 43
         }
35
-        else if (!isset($data->$key)) return false;
36
-        else if (!(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val))
37
-            return in_array($data->$key, $val);
38
-        else
39
-            return $this->processFilter($mode, $val, $data->$key);
40 44
     }
41 45
 
42 46
     private function processFilter($mode, $expected, $actual) {
43
-        if (Maphper::FIND_NOT & $mode) return $expected != $actual;
44
-        else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) return $expected <= $actual;
45
-        else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) return $expected >= $actual;
46
-        else if (Maphper::FIND_GREATER & $mode) return $expected < $actual;
47
-        else if (Maphper::FIND_LESS & $mode) return $expected > $actual;
48
-        else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1];
49
-        else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual);
47
+        if (Maphper::FIND_NOT & $mode) {
48
+        	return $expected != $actual;
49
+        } else if (Maphper::FIND_GREATER & $mode && Maphper::FIND_EXACT & $mode) {
50
+        	return $expected <= $actual;
51
+        } else if (Maphper::FIND_LESS & $mode && Maphper::FIND_EXACT & $mode) {
52
+        	return $expected >= $actual;
53
+        } else if (Maphper::FIND_GREATER & $mode) {
54
+        	return $expected < $actual;
55
+        } else if (Maphper::FIND_LESS & $mode) {
56
+        	return $expected > $actual;
57
+        } else if (Maphper::FIND_BETWEEN & $mode) {
58
+        	return $expected[0] <= $actual && $actual <= $expected[1];
59
+        } else if (Maphper::FIND_NOCASE & $mode) {
60
+        	return strtolower($expected) == strtolower($actual);
61
+        }
50 62
         return $expected == $actual;
51 63
     }
52 64
 }
Please login to merge, or discard this patch.
maphper/datasource/mock.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -2,76 +2,76 @@
 block discarded – undo
2 2
 namespace Maphper\DataSource;
3 3
 use Maphper\Maphper;
4 4
 class Mock implements \Maphper\DataSource {
5
-    private $data;
6
-    private $id;
5
+	private $data;
6
+	private $id;
7 7
 
8
-    public function __construct(\ArrayObject $data, $id) {
9
-        $this->data = $data;
10
-        $this->id = is_array($id) ? $id : [$id];
11
-    }
8
+	public function __construct(\ArrayObject $data, $id) {
9
+		$this->data = $data;
10
+		$this->id = is_array($id) ? $id : [$id];
11
+	}
12 12
 
13
-    public function getPrimaryKey() {
14
-        return $this->id;
15
-    }
13
+	public function getPrimaryKey() {
14
+		return $this->id;
15
+	}
16 16
 
17
-    public function findById($id) {
18
-        return isset($this->data[$id]) ? (array)$this->data[$id] : [];
19
-    }
17
+	public function findById($id) {
18
+		return isset($this->data[$id]) ? (array)$this->data[$id] : [];
19
+	}
20 20
 
21
-    public function findByField(array $fields, $options = []) {
22
-        $arrayFilter = new \Maphper\Lib\ArrayFilter(iterator_to_array($this->data->getIterator()));
23
-        $filteredArray = $arrayFilter->filter($fields);
24
-        if (isset($options['order'])) {
25
-            list($columns, $order) = explode(' ', $options['order']);
26
-            usort($filteredArray, $this->getOrderFunction($order, $columns));
27
-        }
28
-        if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']);
29
-        if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']);
30
-        return $filteredArray;
31
-    }
21
+	public function findByField(array $fields, $options = []) {
22
+		$arrayFilter = new \Maphper\Lib\ArrayFilter(iterator_to_array($this->data->getIterator()));
23
+		$filteredArray = $arrayFilter->filter($fields);
24
+		if (isset($options['order'])) {
25
+			list($columns, $order) = explode(' ', $options['order']);
26
+			usort($filteredArray, $this->getOrderFunction($order, $columns));
27
+		}
28
+		if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']);
29
+		if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']);
30
+		return $filteredArray;
31
+	}
32 32
 
33 33
   	public function findAggregate($function, $field, $group = null, array $criteria = [], array $options = []) {
34
-        return $function($this->findByField($criteria));
35
-    }
34
+		return $function($this->findByField($criteria));
35
+	}
36 36
 
37 37
   	public function deleteById($id) {
38
-        unset($this->data[$id]);
39
-    }
38
+		unset($this->data[$id]);
39
+	}
40 40
 
41 41
   	public function deleteByField(array $fields, array $options) {
42
-        foreach ($this->findByField($fields, $options) as $val) unset($this->data[$val->{$this->id[0]}]);
43
-    }
42
+		foreach ($this->findByField($fields, $options) as $val) unset($this->data[$val->{$this->id[0]}]);
43
+	}
44 44
 
45
-    public function save($data) {
46
-        if (isset($data->{$this->id[0]})) {
47
-            $id = $data->{$this->id[0]};
48
-        }
49
-        else {
50
-            $id = count($this->data);
51
-            $data->{$this->id[0]} = $id;
52
-        }
45
+	public function save($data) {
46
+		if (isset($data->{$this->id[0]})) {
47
+			$id = $data->{$this->id[0]};
48
+		}
49
+		else {
50
+			$id = count($this->data);
51
+			$data->{$this->id[0]} = $id;
52
+		}
53 53
 
54
-        $this->data[$id] = (object)array_merge($this->findById($id), (array)$data);
55
-    }
54
+		$this->data[$id] = (object)array_merge($this->findById($id), (array)$data);
55
+	}
56 56
 
57
-    public function getErrors() {
58
-        return [];
59
-    }
57
+	public function getErrors() {
58
+		return [];
59
+	}
60 60
 
61
-    private function getOrderFunction($order, $columns) {
62
-        return function($a, $b) use ($order, $columns) {
63
-          foreach (explode(',', $columns) as $column) {
64
-            $aColumn = $a->$column;
65
-            $bColumn = $b->$column;
66
-            if ($aColumn === $bColumn) {
67
-              $sortVal = 0;
68
-              continue;
69
-            }
70
-            else $sortVal = ($aColumn < $bColumn) ? -1 : 1;
71
-            break;
72
-          }
73
-          if ($order === 'desc') return -$sortVal;
74
-          else return $sortVal;
75
-        };
76
-    }
61
+	private function getOrderFunction($order, $columns) {
62
+		return function($a, $b) use ($order, $columns) {
63
+		  foreach (explode(',', $columns) as $column) {
64
+			$aColumn = $a->$column;
65
+			$bColumn = $b->$column;
66
+			if ($aColumn === $bColumn) {
67
+			  $sortVal = 0;
68
+			  continue;
69
+			}
70
+			else $sortVal = ($aColumn < $bColumn) ? -1 : 1;
71
+			break;
72
+		  }
73
+		  if ($order === 'desc') return -$sortVal;
74
+		  else return $sortVal;
75
+		};
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,8 +25,12 @@  discard block
 block discarded – undo
25 25
             list($columns, $order) = explode(' ', $options['order']);
26 26
             usort($filteredArray, $this->getOrderFunction($order, $columns));
27 27
         }
28
-        if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']);
29
-        if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']);
28
+        if (isset($options['offset'])) {
29
+        	$filteredArray = array_slice($filteredArray, $options['offset']);
30
+        }
31
+        if (isset($options['limit'])) {
32
+        	$filteredArray = array_slice($filteredArray, 0, $options['limit']);
33
+        }
30 34
         return $filteredArray;
31 35
     }
32 36
 
@@ -39,14 +43,15 @@  discard block
 block discarded – undo
39 43
     }
40 44
 
41 45
   	public function deleteByField(array $fields, array $options) {
42
-        foreach ($this->findByField($fields, $options) as $val) unset($this->data[$val->{$this->id[0]}]);
46
+        foreach ($this->findByField($fields, $options) as $val) {
47
+        	unset($this->data[$val->{$this->id[0]}]);
48
+        }
43 49
     }
44 50
 
45 51
     public function save($data) {
46 52
         if (isset($data->{$this->id[0]})) {
47 53
             $id = $data->{$this->id[0]};
48
-        }
49
-        else {
54
+        } else {
50 55
             $id = count($this->data);
51 56
             $data->{$this->id[0]} = $id;
52 57
         }
@@ -66,12 +71,16 @@  discard block
 block discarded – undo
66 71
             if ($aColumn === $bColumn) {
67 72
               $sortVal = 0;
68 73
               continue;
74
+            } else {
75
+            	$sortVal = ($aColumn < $bColumn) ? -1 : 1;
69 76
             }
70
-            else $sortVal = ($aColumn < $bColumn) ? -1 : 1;
71 77
             break;
72 78
           }
73
-          if ($order === 'desc') return -$sortVal;
74
-          else return $sortVal;
79
+          if ($order === 'desc') {
80
+          	return -$sortVal;
81
+          } else {
82
+          	return $sortVal;
83
+          }
75 84
         };
76 85
     }
77 86
 }
Please login to merge, or discard this patch.
maphper/lib/Sql/WhereConditional.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 block discarded – undo
2 2
 namespace Maphper\Lib\Sql;
3 3
 
4 4
 interface WhereConditional {
5
-    public function matches($key, $value, $mode);
6
-    public function getSql($key, $value, $mode);
5
+	public function matches($key, $value, $mode);
6
+	public function getSql($key, $value, $mode);
7 7
 }
Please login to merge, or discard this patch.
maphper/lib/Sql/In.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,21 +2,21 @@
 block discarded – undo
2 2
 namespace Maphper\Lib\Sql;
3 3
 
4 4
 class In implements WhereConditional {
5
-    public function matches($key, $value, $mode) {
6
-        return !is_numeric($key) && is_array($value);
7
-    }
5
+	public function matches($key, $value, $mode) {
6
+		return !is_numeric($key) && is_array($value);
7
+	}
8 8
 
9
-    public function getSql($key, $value, $mode) {
10
-        $args = [];
11
-        $inSql = [];
12
-        $count = count($value);
13
-        for ($i = 0; $i < $count; $i++) {
14
-            $args[$key . $i] = $value[$i];
15
-            $inSql[] = ':' . $key . $i;
16
-        }
17
-        if (count($inSql) == 0) return [];
18
-        else $sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
9
+	public function getSql($key, $value, $mode) {
10
+		$args = [];
11
+		$inSql = [];
12
+		$count = count($value);
13
+		for ($i = 0; $i < $count; $i++) {
14
+			$args[$key . $i] = $value[$i];
15
+			$inSql[] = ':' . $key . $i;
16
+		}
17
+		if (count($inSql) == 0) return [];
18
+		else $sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
19 19
 
20
-        return ['args' => $args, 'sql' => $sql];
21
-    }
20
+		return ['args' => $args, 'sql' => $sql];
21
+	}
22 22
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
             $inSql[] = ':' . $key . $i;
16 16
         }
17 17
         if (count($inSql) == 0) return [];
18
-        else $sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
18
+        else $sql = [$key . ' IN ( ' . implode(', ', $inSql) . ')'];
19 19
 
20 20
         return ['args' => $args, 'sql' => $sql];
21 21
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,11 @@
 block discarded – undo
14 14
             $args[$key . $i] = $value[$i];
15 15
             $inSql[] = ':' . $key . $i;
16 16
         }
17
-        if (count($inSql) == 0) return [];
18
-        else $sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
17
+        if (count($inSql) == 0) {
18
+        	return [];
19
+        } else {
20
+        	$sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
21
+        }
19 22
 
20 23
         return ['args' => $args, 'sql' => $sql];
21 24
     }
Please login to merge, or discard this patch.
maphper/lib/Sql/Between.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@
 block discarded – undo
2 2
 namespace Maphper\Lib\Sql;
3 3
 
4 4
 class Between implements WhereConditional {
5
-    public function matches($key, $value, $mode) {
6
-        return is_array($value) && \Maphper\Maphper::FIND_BETWEEN & $mode;
7
-    }
5
+	public function matches($key, $value, $mode) {
6
+		return is_array($value) && \Maphper\Maphper::FIND_BETWEEN & $mode;
7
+	}
8 8
 
9
-    public function getSql($key, $value, $mode) {
10
-        return [
11
-            'sql' => [
12
-                $key . '>= :' . $key . 'from',
13
-                $key . ' <= :' . $key . 'to'
14
-            ],
15
-            'args' => [
16
-                $key . 'from' => $value[0],
17
-                $key . 'to' => $value[1]
18
-            ]
19
-        ];
20
-    }
9
+	public function getSql($key, $value, $mode) {
10
+		return [
11
+			'sql' => [
12
+				$key . '>= :' . $key . 'from',
13
+				$key . ' <= :' . $key . 'to'
14
+			],
15
+			'args' => [
16
+				$key . 'from' => $value[0],
17
+				$key . 'to' => $value[1]
18
+			]
19
+		];
20
+	}
21 21
 }
Please login to merge, or discard this patch.
maphper/lib/Sql/NullConditional.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 namespace Maphper\Lib\Sql;
3 3
 
4 4
 class NullConditional implements WhereConditional {
5
-    public function matches($key, $value, $mode) {
6
-        return $value === NULL;
7
-    }
5
+	public function matches($key, $value, $mode) {
6
+		return $value === NULL;
7
+	}
8 8
 
9
-    public function getSql($key, $value, $mode) {
10
-        $nullSql = $key . ' IS ';
11
-        if (\Maphper\Maphper::FIND_NOT & $mode) $nullSql .= 'NOT ';
12
-        $sql = [$nullSql . 'NULL'];
9
+	public function getSql($key, $value, $mode) {
10
+		$nullSql = $key . ' IS ';
11
+		if (\Maphper\Maphper::FIND_NOT & $mode) $nullSql .= 'NOT ';
12
+		$sql = [$nullSql . 'NULL'];
13 13
 
14
-        return ['args' => [], 'sql' => $sql];
15
-    }
14
+		return ['args' => [], 'sql' => $sql];
15
+	}
16 16
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@
 block discarded – undo
8 8
 
9 9
     public function getSql($key, $value, $mode) {
10 10
         $nullSql = $key . ' IS ';
11
-        if (\Maphper\Maphper::FIND_NOT & $mode) $nullSql .= 'NOT ';
11
+        if (\Maphper\Maphper::FIND_NOT & $mode) {
12
+        	$nullSql .= 'NOT ';
13
+        }
12 14
         $sql = [$nullSql . 'NULL'];
13 15
 
14 16
         return ['args' => [], 'sql' => $sql];
Please login to merge, or discard this patch.
maphper/lib/Sql/Like.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -3,21 +3,21 @@
 block discarded – undo
3 3
 use Maphper\Maphper;
4 4
 
5 5
 class Like implements WhereConditional {
6
-    public function matches($key, $value, $mode) {
7
-        return (Maphper::FIND_LIKE | Maphper::FIND_STARTS |
8
-                Maphper::FIND_ENDS | Maphper::FIND_NOCASE) & $mode;
9
-    }
6
+	public function matches($key, $value, $mode) {
7
+		return (Maphper::FIND_LIKE | Maphper::FIND_STARTS |
8
+				Maphper::FIND_ENDS | Maphper::FIND_NOCASE) & $mode;
9
+	}
10 10
 
11
-    public function getSql($key, $value, $mode) {
12
-        return [
13
-            'sql' => [$key . ' LIKE :' . $key],
14
-            'args' => [$key => $this->getValue($value, $mode)]
15
-        ];
16
-    }
11
+	public function getSql($key, $value, $mode) {
12
+		return [
13
+			'sql' => [$key . ' LIKE :' . $key],
14
+			'args' => [$key => $this->getValue($value, $mode)]
15
+		];
16
+	}
17 17
 
18
-    private function getValue($value, $mode) {
19
-        if ((Maphper::FIND_LIKE | Maphper::FIND_ENDS) & $mode) $value = '%' . $value;
20
-        if ((Maphper::FIND_LIKE | Maphper::FIND_STARTS) & $mode) $value .= '%';
21
-        return $value;
22
-    }
18
+	private function getValue($value, $mode) {
19
+		if ((Maphper::FIND_LIKE | Maphper::FIND_ENDS) & $mode) $value = '%' . $value;
20
+		if ((Maphper::FIND_LIKE | Maphper::FIND_STARTS) & $mode) $value .= '%';
21
+		return $value;
22
+	}
23 23
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@
 block discarded – undo
16 16
     }
17 17
 
18 18
     private function getValue($value, $mode) {
19
-        if ((Maphper::FIND_LIKE | Maphper::FIND_ENDS) & $mode) $value = '%' . $value;
20
-        if ((Maphper::FIND_LIKE | Maphper::FIND_STARTS) & $mode) $value .= '%';
19
+        if ((Maphper::FIND_LIKE | Maphper::FIND_ENDS) & $mode) {
20
+        	$value = '%' . $value;
21
+        }
22
+        if ((Maphper::FIND_LIKE | Maphper::FIND_STARTS) & $mode) {
23
+        	$value .= '%';
24
+        }
21 25
         return $value;
22 26
     }
23 27
 }
Please login to merge, or discard this patch.
maphper/lib/Sql/WhereBuilder.php 3 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -2,65 +2,65 @@
 block discarded – undo
2 2
 namespace Maphper\Lib\Sql;
3 3
 
4 4
 class WhereBuilder {
5
-    private $conditionals = [];
5
+	private $conditionals = [];
6 6
 
7
-    public function __construct() {
8
-        $defaultConditionals = [
9
-            'Maphper\Lib\Sql\Between',
10
-            'Maphper\Lib\Sql\In',
11
-            'Maphper\Lib\Sql\NullConditional',
12
-            'Maphper\Lib\Sql\Like',
13
-            'Maphper\Lib\Sql\GeneralOperator'
14
-        ];
7
+	public function __construct() {
8
+		$defaultConditionals = [
9
+			'Maphper\Lib\Sql\Between',
10
+			'Maphper\Lib\Sql\In',
11
+			'Maphper\Lib\Sql\NullConditional',
12
+			'Maphper\Lib\Sql\Like',
13
+			'Maphper\Lib\Sql\GeneralOperator'
14
+		];
15 15
 
16
-        foreach ($defaultConditionals as $conditional) $this->addConditional(new $conditional);
17
-    }
16
+		foreach ($defaultConditionals as $conditional) $this->addConditional(new $conditional);
17
+	}
18 18
 
19
-    public function addConditional(WhereConditional $conditional) {
20
-        $this->conditionals[] = $conditional;
21
-    }
19
+	public function addConditional(WhereConditional $conditional) {
20
+		$this->conditionals[] = $conditional;
21
+	}
22 22
 
23 23
 	public function createSql($fields, $mode = \Maphper\Maphper::FIND_EXACT | \Maphper\Maphper::FIND_AND) {
24 24
 		$args = [];
25 25
 		$sql = [];
26 26
 
27
-        foreach ($fields as $key => $value) {
28
-            $value = $this->convertDates($value);
27
+		foreach ($fields as $key => $value) {
28
+			$value = $this->convertDates($value);
29 29
 
30
-            if (is_object($value)) continue;
30
+			if (is_object($value)) continue;
31 31
 			if (is_numeric($key) && is_array($value)) {
32 32
 				$result = $this->createSql($value, $key);
33 33
 			}
34
-            else {
35
-                $result = $this->getConditional($key, $value, $mode);
36
-            }
37
-            $sql = array_merge($sql, (array)$result['sql']);
38
-            $args = array_merge($args, $result['args']);
39
-        }
34
+			else {
35
+				$result = $this->getConditional($key, $value, $mode);
36
+			}
37
+			$sql = array_merge($sql, (array)$result['sql']);
38
+			$args = array_merge($args, $result['args']);
39
+		}
40 40
 
41 41
 		return ['args' => $args, 'sql' => $this->sqlArrayToString($sql, $mode)];
42 42
 	}
43 43
 
44
-    private function sqlArrayToString($sql, $mode) {
45
-        if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
44
+	private function sqlArrayToString($sql, $mode) {
45
+		if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
46 46
 		else $query = implode(' AND ', $sql);
47 47
 		if (!empty($query)) $query = '(' . $query . ')';
48
-        return $query;
49
-    }
48
+		return $query;
49
+	}
50 50
 
51
-    private function getConditional($key, $value, $mode) {
52
-        foreach ($this->conditionals as $conditional) {
53
-            if ($conditional->matches($key, $value, $mode))
54
-                return $conditional->getSql($key, $value, $mode);
55
-        }
56
-        throw new \Exception("Invalid WHERE query");
57
-    }
51
+	private function getConditional($key, $value, $mode) {
52
+		foreach ($this->conditionals as $conditional) {
53
+			if ($conditional->matches($key, $value, $mode))
54
+				return $conditional->getSql($key, $value, $mode);
55
+		}
56
+		throw new \Exception("Invalid WHERE query");
57
+	}
58 58
 
59
-    private function convertDates($value) {
60
-        if ($value instanceof \DateTime) {
61
-            if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
62
-            else $value = $value->format('Y-m-d H:i:s');
63
-        }
64
-        return $value;
65
-    }
59
+	private function convertDates($value) {
60
+		if ($value instanceof \DateTime) {
61
+			if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
62
+			else $value = $value->format('Y-m-d H:i:s');
63
+		}
64
+		return $value;
65
+	}
66 66
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 
59 59
     private function convertDates($value) {
60 60
         if ($value instanceof \DateTime) {
61
-            if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
61
+            if ($value->format('H:i:s') == '00:00:00') $value = $value->format('Y-m-d');
62 62
             else $value = $value->format('Y-m-d H:i:s');
63 63
         }
64 64
         return $value;
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
             'Maphper\Lib\Sql\GeneralOperator'
14 14
         ];
15 15
 
16
-        foreach ($defaultConditionals as $conditional) $this->addConditional(new $conditional);
16
+        foreach ($defaultConditionals as $conditional) {
17
+        	$this->addConditional(new $conditional);
18
+        }
17 19
     }
18 20
 
19 21
     public function addConditional(WhereConditional $conditional) {
@@ -27,11 +29,12 @@  discard block
 block discarded – undo
27 29
         foreach ($fields as $key => $value) {
28 30
             $value = $this->convertDates($value);
29 31
 
30
-            if (is_object($value)) continue;
32
+            if (is_object($value)) {
33
+            	continue;
34
+            }
31 35
 			if (is_numeric($key) && is_array($value)) {
32 36
 				$result = $this->createSql($value, $key);
33
-			}
34
-            else {
37
+			} else {
35 38
                 $result = $this->getConditional($key, $value, $mode);
36 39
             }
37 40
             $sql = array_merge($sql, (array)$result['sql']);
@@ -42,24 +45,33 @@  discard block
 block discarded – undo
42 45
 	}
43 46
 
44 47
     private function sqlArrayToString($sql, $mode) {
45
-        if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
46
-		else $query = implode(' AND ', $sql);
47
-		if (!empty($query)) $query = '(' . $query . ')';
48
+        if (\Maphper\Maphper::FIND_OR & $mode) {
49
+        	$query = implode(' OR  ', $sql);
50
+        } else {
51
+			$query = implode(' AND ', $sql);
52
+		}
53
+		if (!empty($query)) {
54
+			$query = '(' . $query . ')';
55
+		}
48 56
         return $query;
49 57
     }
50 58
 
51 59
     private function getConditional($key, $value, $mode) {
52 60
         foreach ($this->conditionals as $conditional) {
53
-            if ($conditional->matches($key, $value, $mode))
54
-                return $conditional->getSql($key, $value, $mode);
61
+            if ($conditional->matches($key, $value, $mode)) {
62
+                            return $conditional->getSql($key, $value, $mode);
63
+            }
55 64
         }
56 65
         throw new \Exception("Invalid WHERE query");
57 66
     }
58 67
 
59 68
     private function convertDates($value) {
60 69
         if ($value instanceof \DateTime) {
61
-            if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
62
-            else $value = $value->format('Y-m-d H:i:s');
70
+            if ($value->format('H:i:s')  == '00:00:00') {
71
+            	$value = $value->format('Y-m-d');
72
+            } else {
73
+            	$value = $value->format('Y-m-d H:i:s');
74
+            }
63 75
         }
64 76
         return $value;
65 77
     }
Please login to merge, or discard this patch.