Passed
Push — master ( 562277...03179d )
by Richard
01:52
created
maphper/lib/dateinjector.php 1 patch
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.
maphper/lib/visibilityoverride.php 1 patch
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.
maphper/lib/ArrayFilter.php 1 patch
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.
maphper/lib/entity.php 1 patch
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.
maphper/lib/Sql/WhereBuilder.php 1 patch
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.