Passed
Push — master ( 03179d...66acfb )
by Richard
01:36
created
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/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.
maphper/lib/ArrayFilter.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -3,58 +3,58 @@
 block discarded – undo
3 3
 use Maphper\Maphper;
4 4
 
5 5
 class ArrayFilter {
6
-    private $array;
7
-
8
-    public function __construct(array $array) {
9
-        $this->array = $array;
10
-    }
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
-    }
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);
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 (bool)(Maphper::FIND_OR ^ $mode);
28
-        };
29
-    }
30
-
31
-    private function getIfFieldMatches($key, $val, $data, $mode) {
32
-        if ($this->shouldRunDeepSearch($key, $val)) {
33
-            return $this->getSearchFieldFunction($val, $key)($data);
34
-        }
35
-        else if (!isset($data->$key)) return false;
36
-        else if ($this->isInArraySearch($mode, $key, $val))
37
-            return in_array($data->$key, $val);
38
-        else
39
-            return $this->processFilter($mode, $val, $data->$key);
40
-    }
41
-
42
-    private function shouldRunDeepSearch($key, $val) {
43
-        return is_numeric($key) && is_array($val);
44
-    }
45
-
46
-    private function isInArraySearch($mode, $key, $val) {
47
-        return !(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val);
48
-    }
49
-
50
-    private function processFilter($mode, $expected, $actual) {
51
-        if (Maphper::FIND_NOT & $mode) return $expected != $actual;
52
-        else if ((Maphper::FIND_GREATER | Maphper::FIND_EXACT) === $mode) return $expected <= $actual;
53
-        else if ((Maphper::FIND_LESS | Maphper::FIND_EXACT) === $mode) return $expected >= $actual;
54
-        else if (Maphper::FIND_GREATER & $mode) return $expected < $actual;
55
-        else if (Maphper::FIND_LESS & $mode) return $expected > $actual;
56
-        else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1];
57
-        else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual);
58
-        return $expected == $actual;
59
-    }
6
+	private $array;
7
+
8
+	public function __construct(array $array) {
9
+		$this->array = $array;
10
+	}
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
+	}
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);
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 (bool)(Maphper::FIND_OR ^ $mode);
28
+		};
29
+	}
30
+
31
+	private function getIfFieldMatches($key, $val, $data, $mode) {
32
+		if ($this->shouldRunDeepSearch($key, $val)) {
33
+			return $this->getSearchFieldFunction($val, $key)($data);
34
+		}
35
+		else if (!isset($data->$key)) return false;
36
+		else if ($this->isInArraySearch($mode, $key, $val))
37
+			return in_array($data->$key, $val);
38
+		else
39
+			return $this->processFilter($mode, $val, $data->$key);
40
+	}
41
+
42
+	private function shouldRunDeepSearch($key, $val) {
43
+		return is_numeric($key) && is_array($val);
44
+	}
45
+
46
+	private function isInArraySearch($mode, $key, $val) {
47
+		return !(Maphper::FIND_BETWEEN & $mode) && !is_numeric($key) && is_array($val);
48
+	}
49
+
50
+	private function processFilter($mode, $expected, $actual) {
51
+		if (Maphper::FIND_NOT & $mode) return $expected != $actual;
52
+		else if ((Maphper::FIND_GREATER | Maphper::FIND_EXACT) === $mode) return $expected <= $actual;
53
+		else if ((Maphper::FIND_LESS | Maphper::FIND_EXACT) === $mode) return $expected >= $actual;
54
+		else if (Maphper::FIND_GREATER & $mode) return $expected < $actual;
55
+		else if (Maphper::FIND_LESS & $mode) return $expected > $actual;
56
+		else if (Maphper::FIND_BETWEEN & $mode) return $expected[0] <= $actual && $actual <= $expected[1];
57
+		else if (Maphper::FIND_NOCASE & $mode) return strtolower($expected) == strtolower($actual);
58
+		return $expected == $actual;
59
+	}
60 60
 }
Please login to merge, or discard this patch.