Passed
Push — master ( 380864...509b8c )
by Richard
01:39
created
maphper/datasource/mock.php 1 patch
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.
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 1 patch
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.
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 1 patch
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.
maphper/lib/Sql/Like.php 1 patch
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.
maphper/lib/Sql/GeneralOperator.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -3,33 +3,33 @@
 block discarded – undo
3 3
 use Maphper\Maphper;
4 4
 
5 5
 class GeneralOperator implements WhereConditional {
6
-    public function matches($key, $value, $mode) {
7
-        return (Maphper::FIND_BIT ^ Maphper::FIND_GREATER ^ Maphper::FIND_LESS ^ Maphper::FIND_NOT & $mode)
8
-                || Maphper::FIND_EXACT & $mode;
9
-    }
6
+	public function matches($key, $value, $mode) {
7
+		return (Maphper::FIND_BIT ^ Maphper::FIND_GREATER ^ Maphper::FIND_LESS ^ Maphper::FIND_NOT & $mode)
8
+				|| Maphper::FIND_EXACT & $mode;
9
+	}
10 10
 
11
-    public function getSql($key, $value, $mode) {
12
-        return [
13
-            'sql' => [$key . ' ' . $this->getOperator($mode) . ' :' . $key],
14
-            'args' => [$key => $value]
15
-        ];
16
-    }
11
+	public function getSql($key, $value, $mode) {
12
+		return [
13
+			'sql' => [$key . ' ' . $this->getOperator($mode) . ' :' . $key],
14
+			'args' => [$key => $value]
15
+		];
16
+	}
17 17
 
18
-    private function getOperator($mode) {
19
-        if (\Maphper\Maphper::FIND_BIT & $mode) return '&';
20
-        else if (\Maphper\Maphper::FIND_NOT & $mode) return '!=';
18
+	private function getOperator($mode) {
19
+		if (\Maphper\Maphper::FIND_BIT & $mode) return '&';
20
+		else if (\Maphper\Maphper::FIND_NOT & $mode) return '!=';
21 21
 
22
-        return $this->getEqualsOperators($mode);
23
-    }
22
+		return $this->getEqualsOperators($mode);
23
+	}
24 24
 
25
-    private function getEqualsOperators($mode) {
26
-        $operator = "";
25
+	private function getEqualsOperators($mode) {
26
+		$operator = "";
27 27
 
28
-        if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>';
29
-        else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<';
28
+		if (\Maphper\Maphper::FIND_GREATER & $mode) $operator = '>';
29
+		else if (\Maphper\Maphper::FIND_LESS & $mode) $operator = '<';
30 30
 
31
-        if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '=';
31
+		if (\Maphper\Maphper::FIND_EXACT & $mode) $operator .= '=';
32 32
 
33
-        return $operator;
34
-    }
33
+		return $operator;
34
+	}
35 35
 }
Please login to merge, or discard this patch.
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.