Passed
Push — master ( 562277...03179d )
by Richard
01:52
created
maphper/lib/dateinjector.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@
 block discarded – undo
13 13
 		return $obj;
14 14
 	}
15 15
 
16
-    private function tryToGetDateObjFromString($obj) {
17
-        try {
18
-            $date = new \DateTime($obj);
19
-            if ($date->format('Y-m-d H:i:s') == substr($obj, 0, 20) || $date->format('Y-m-d') == substr($obj, 0, 10)) $obj = $date;
20
-        }
21
-        catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
22
-        }
23
-        return $obj;
24
-    }
25
-
26
-    private function isIterable($obj) {
27
-        return is_array($obj) || (is_object($obj) && ($obj instanceof \Iterator));
28
-    }
29
-
30
-    private function isPossiblyDateString($obj) {
31
-        return is_string($obj) && isset($obj[0]) && is_numeric($obj[0]) && strlen($obj) <= 20;
32
-    }
16
+	private function tryToGetDateObjFromString($obj) {
17
+		try {
18
+			$date = new \DateTime($obj);
19
+			if ($date->format('Y-m-d H:i:s') == substr($obj, 0, 20) || $date->format('Y-m-d') == substr($obj, 0, 10)) $obj = $date;
20
+		}
21
+		catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
22
+		}
23
+		return $obj;
24
+	}
25
+
26
+	private function isIterable($obj) {
27
+		return is_array($obj) || (is_object($obj) && ($obj instanceof \Iterator));
28
+	}
29
+
30
+	private function isPossiblyDateString($obj) {
31
+		return is_string($obj) && isset($obj[0]) && is_numeric($obj[0]) && strlen($obj) <= 20;
32
+	}
33 33
 
34 34
 	private function checkCache($obj, $reset) {
35 35
 		if ($reset) $this->processCache = new \SplObjectStorage();
36
-        if (!is_object($obj)) return false;
36
+		if (!is_object($obj)) return false;
37 37
 
38 38
 		if ($this->processCache->contains($obj)) return $obj;
39 39
 		else $this->processCache->attach($obj, true);
Please login to merge, or discard this patch.
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,19 +6,26 @@  discard block
 block discarded – undo
6 6
 
7 7
 	public function replaceDates($obj, $reset = true) {
8 8
 		//prevent infinite recursion, only process each object once
9
-		if ($this->checkCache($obj, $reset)) return $obj;
10
-
11
-		if ($this->isIterable($obj)) foreach ($obj as &$o) $o = $this->replaceDates($o, false);
12
-		if ($this->isPossiblyDateString($obj)) $obj = $this->tryToGetDateObjFromString($obj);
9
+		if ($this->checkCache($obj, $reset)) {
10
+			return $obj;
11
+		}
12
+
13
+		if ($this->isIterable($obj)) {
14
+			foreach ($obj as &$o) $o = $this->replaceDates($o, false);
15
+		}
16
+		if ($this->isPossiblyDateString($obj)) {
17
+			$obj = $this->tryToGetDateObjFromString($obj);
18
+		}
13 19
 		return $obj;
14 20
 	}
15 21
 
16 22
     private function tryToGetDateObjFromString($obj) {
17 23
         try {
18 24
             $date = new \DateTime($obj);
19
-            if ($date->format('Y-m-d H:i:s') == substr($obj, 0, 20) || $date->format('Y-m-d') == substr($obj, 0, 10)) $obj = $date;
20
-        }
21
-        catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
25
+            if ($date->format('Y-m-d H:i:s') == substr($obj, 0, 20) || $date->format('Y-m-d') == substr($obj, 0, 10)) {
26
+            	$obj = $date;
27
+            }
28
+        } catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
22 29
         }
23 30
         return $obj;
24 31
     }
@@ -32,11 +39,18 @@  discard block
 block discarded – undo
32 39
     }
33 40
 
34 41
 	private function checkCache($obj, $reset) {
35
-		if ($reset) $this->processCache = new \SplObjectStorage();
36
-        if (!is_object($obj)) return false;
42
+		if ($reset) {
43
+			$this->processCache = new \SplObjectStorage();
44
+		}
45
+        if (!is_object($obj)) {
46
+        	return false;
47
+        }
37 48
 
38
-		if ($this->processCache->contains($obj)) return $obj;
39
-		else $this->processCache->attach($obj, true);
49
+		if ($this->processCache->contains($obj)) {
50
+			return $obj;
51
+		} else {
52
+			$this->processCache->attach($obj, true);
53
+		}
40 54
 
41 55
 		return false;
42 56
 	}
Please login to merge, or discard this patch.
maphper/lib/visibilityoverride.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 			$this->writeClosure = function ($field, $value) use ($object) { $object->$field = $value; };
12 12
 		}
13 13
 		else {
14
-            $visOverride = $this;
14
+			$visOverride = $this;
15 15
 			$this->readClosure = function() use ($visOverride) {
16
-                return (object) array_filter(get_object_vars($this), [$visOverride, 'isReturnableDataType']);
16
+				return (object) array_filter(get_object_vars($this), [$visOverride, 'isReturnableDataType']);
17 17
 			};
18 18
 			$this->readClosure = $this->readClosure->bindTo($object, $object);
19 19
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 
24 24
 	}
25 25
 
26
-    public function isReturnableDataType($v) {
27
-        return is_scalar($v) || is_null($v) || (is_object($v) && $v instanceof \DateTime);
28
-    }
26
+	public function isReturnableDataType($v) {
27
+		return is_scalar($v) || is_null($v) || (is_object($v) && $v instanceof \DateTime);
28
+	}
29 29
 
30 30
 	public function getProperties() {
31 31
 		return ($this->readClosure)();
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public function __construct($object) {
9 9
 		if ($object instanceof \stdclass) {
10
-			$this->readClosure = function() use ($object) { return $object;	};
11
-			$this->writeClosure = function ($field, $value) use ($object) { $object->$field = $value; };
10
+			$this->readClosure = function() use ($object) { return $object; };
11
+			$this->writeClosure = function($field, $value) use ($object) { $object->$field = $value; };
12 12
 		}
13 13
 		else {
14 14
             $visOverride = $this;
15 15
 			$this->readClosure = function() use ($visOverride) {
16
-                return (object) array_filter(get_object_vars($this), [$visOverride, 'isReturnableDataType']);
16
+                return (object)array_filter(get_object_vars($this), [$visOverride, 'isReturnableDataType']);
17 17
 			};
18 18
 			$this->readClosure = $this->readClosure->bindTo($object, $object);
19 19
 
20
-			$this->writeClosure = function ($field, $value) { $this->$field = $value; };
20
+			$this->writeClosure = function($field, $value) { $this->$field = $value; };
21 21
 			$this->writeClosure = $this->writeClosure->bindTo($object, $object);
22 22
 		}
23 23
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	public function write($data) {
35 35
 		if ($data != null) {
36 36
 			foreach ($data as $key => $value) {
37
-				($this->writeClosure)($key,  $this->processDates($value));
37
+				($this->writeClosure)($key, $this->processDates($value));
38 38
 			}
39 39
 		}
40 40
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 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
             $visOverride = $this;
15 14
 			$this->readClosure = function() use ($visOverride) {
16 15
                 return (object) array_filter(get_object_vars($this), [$visOverride, 'isReturnableDataType']);
Please login to merge, or discard this patch.
maphper/lib/ArrayFilter.php 2 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 | Maphper::FIND_EXACT) === $mode) return $expected <= $actual;
45
-        else if ((Maphper::FIND_LESS | 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 | Maphper::FIND_EXACT) === $mode) return $expected <= $actual;
45
+		else if ((Maphper::FIND_LESS | 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.
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 | Maphper::FIND_EXACT) === $mode) return $expected <= $actual;
45
-        else if ((Maphper::FIND_LESS | 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 | Maphper::FIND_EXACT) === $mode) {
50
+        	return $expected <= $actual;
51
+        } else if ((Maphper::FIND_LESS | 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/lib/entity.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	private $parent;
9 9
 
10 10
 	public function __construct(\Maphper\Maphper $parent, $className = null) {
11
-        $this->parent = $parent;
11
+		$this->parent = $parent;
12 12
 		$this->className = $className;
13 13
 	}
14 14
 
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 		return $object;
26 26
 	}
27 27
 
28
-    private function addRelationData($object, $name, $relation, $siblings) {
29
-        if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation) ) {
30
-            //After overwriting the relation, does the parent object ($object) need overwriting as well?
31
-            if ($relation->overwrite($object, $object->$name)) $this->parent[] = $object;
32
-        }
28
+	private function addRelationData($object, $name, $relation, $siblings) {
29
+		if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation) ) {
30
+			//After overwriting the relation, does the parent object ($object) need overwriting as well?
31
+			if ($relation->overwrite($object, $object->$name)) $this->parent[] = $object;
32
+		}
33 33
 
34
-        $object->$name = $relation->getData($object, $siblings);
35
-    }
34
+		$object->$name = $relation->getData($object, $siblings);
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	}
27 27
 
28 28
     private function addRelationData($object, $name, $relation, $siblings) {
29
-        if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation) ) {
29
+        if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation)) {
30 30
             //After overwriting the relation, does the parent object ($object) need overwriting as well?
31 31
             if ($relation->overwrite($object, $object->$name)) $this->parent[] = $object;
32 32
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,14 +21,18 @@
 block discarded – undo
21 21
 
22 22
 	public function wrap($relations, $object, $siblings = []) {
23 23
 		//see if any relations need overwriting
24
-		foreach ($relations as $name => $relation) $this->addRelationData($object, $name, $relation, $siblings);
24
+		foreach ($relations as $name => $relation) {
25
+			$this->addRelationData($object, $name, $relation, $siblings);
26
+		}
25 27
 		return $object;
26 28
 	}
27 29
 
28 30
     private function addRelationData($object, $name, $relation, $siblings) {
29 31
         if (isset($object->$name) && !($object->$name instanceof \Maphper\Relation) ) {
30 32
             //After overwriting the relation, does the parent object ($object) need overwriting as well?
31
-            if ($relation->overwrite($object, $object->$name)) $this->parent[] = $object;
33
+            if ($relation->overwrite($object, $object->$name)) {
34
+            	$this->parent[] = $object;
35
+            }
32 36
         }
33 37
 
34 38
         $object->$name = $relation->getData($object, $siblings);
Please login to merge, or discard this patch.
maphper/lib/Sql/WhereBuilder.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -2,68 +2,68 @@
 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
 			$result = $this->getResult($key, $value, $mode);
32
-            $sql = array_merge($sql, (array)$result['sql']);
33
-            $args = array_merge($args, $result['args']);
34
-        }
32
+			$sql = array_merge($sql, (array)$result['sql']);
33
+			$args = array_merge($args, $result['args']);
34
+		}
35 35
 
36 36
 		return ['args' => $args, 'sql' => $this->sqlArrayToString($sql, $mode)];
37 37
 	}
38 38
 
39
-    /*
39
+	/*
40 40
      * Either get sql from a conditional or call createSql again because the mode needs to be changed
41 41
      */
42
-    private function getResult($key, $value, $mode) {
43
-        if (is_numeric($key) && is_array($value)) return $this->createSql($value, $key);
44
-        return $this->getConditional($key, $value, $mode);
45
-    }
42
+	private function getResult($key, $value, $mode) {
43
+		if (is_numeric($key) && is_array($value)) return $this->createSql($value, $key);
44
+		return $this->getConditional($key, $value, $mode);
45
+	}
46 46
 
47
-    private function sqlArrayToString($sql, $mode) {
48
-        if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
47
+	private function sqlArrayToString($sql, $mode) {
48
+		if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
49 49
 		else $query = implode(' AND ', $sql);
50 50
 		if (!empty($query)) $query = '(' . $query . ')';
51
-        return $query;
52
-    }
51
+		return $query;
52
+	}
53 53
 
54
-    private function getConditional($key, $value, $mode) {
55
-        foreach ($this->conditionals as $conditional) {
56
-            if ($conditional->matches($key, $value, $mode))
57
-                return $conditional->getSql($key, $value, $mode);
58
-        }
59
-        throw new \Exception("Invalid WHERE query");
60
-    }
54
+	private function getConditional($key, $value, $mode) {
55
+		foreach ($this->conditionals as $conditional) {
56
+			if ($conditional->matches($key, $value, $mode))
57
+				return $conditional->getSql($key, $value, $mode);
58
+		}
59
+		throw new \Exception("Invalid WHERE query");
60
+	}
61 61
 
62
-    private function convertDates($value) {
63
-        if ($value instanceof \DateTime) {
64
-            if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
65
-            else $value = $value->format('Y-m-d H:i:s');
66
-        }
67
-        return $value;
68
-    }
62
+	private function convertDates($value) {
63
+		if ($value instanceof \DateTime) {
64
+			if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
65
+			else $value = $value->format('Y-m-d H:i:s');
66
+		}
67
+		return $value;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 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,7 +29,9 @@  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
 			$result = $this->getResult($key, $value, $mode);
32 36
             $sql = array_merge($sql, (array)$result['sql']);
33 37
             $args = array_merge($args, $result['args']);
@@ -40,29 +44,40 @@  discard block
 block discarded – undo
40 44
      * Either get sql from a conditional or call createSql again because the mode needs to be changed
41 45
      */
42 46
     private function getResult($key, $value, $mode) {
43
-        if (is_numeric($key) && is_array($value)) return $this->createSql($value, $key);
47
+        if (is_numeric($key) && is_array($value)) {
48
+        	return $this->createSql($value, $key);
49
+        }
44 50
         return $this->getConditional($key, $value, $mode);
45 51
     }
46 52
 
47 53
     private function sqlArrayToString($sql, $mode) {
48
-        if (\Maphper\Maphper::FIND_OR & $mode) $query = implode(' OR  ', $sql);
49
-		else $query = implode(' AND ', $sql);
50
-		if (!empty($query)) $query = '(' . $query . ')';
54
+        if (\Maphper\Maphper::FIND_OR & $mode) {
55
+        	$query = implode(' OR  ', $sql);
56
+        } else {
57
+			$query = implode(' AND ', $sql);
58
+		}
59
+		if (!empty($query)) {
60
+			$query = '(' . $query . ')';
61
+		}
51 62
         return $query;
52 63
     }
53 64
 
54 65
     private function getConditional($key, $value, $mode) {
55 66
         foreach ($this->conditionals as $conditional) {
56
-            if ($conditional->matches($key, $value, $mode))
57
-                return $conditional->getSql($key, $value, $mode);
67
+            if ($conditional->matches($key, $value, $mode)) {
68
+                            return $conditional->getSql($key, $value, $mode);
69
+            }
58 70
         }
59 71
         throw new \Exception("Invalid WHERE query");
60 72
     }
61 73
 
62 74
     private function convertDates($value) {
63 75
         if ($value instanceof \DateTime) {
64
-            if ($value->format('H:i:s')  == '00:00:00') $value = $value->format('Y-m-d');
65
-            else $value = $value->format('Y-m-d H:i:s');
76
+            if ($value->format('H:i:s')  == '00:00:00') {
77
+            	$value = $value->format('Y-m-d');
78
+            } else {
79
+            	$value = $value->format('Y-m-d H:i:s');
80
+            }
66 81
         }
67 82
         return $value;
68 83
     }
Please login to merge, or discard this patch.