Completed
Push — master ( dd80d3...71e87d )
by Tom
15s
created
Maphper/Lib/DateInjector.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 		return $obj;
19 19
 	}
20 20
 
21
-    private function tryToGetDateObjFromString($obj) {
22
-        try {
23
-            $date = new \DateTime($obj);
21
+	private function tryToGetDateObjFromString($obj) {
22
+		try {
23
+			$date = new \DateTime($obj);
24 24
 			if ($this->dateMatchesFormats($date, $obj)) $obj = $date;
25
-        }
26
-        catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
27
-        }
28
-        return $obj;
29
-    }
25
+		}
26
+		catch (\Exception $e) {	//Doesn't need to do anything as the try/catch is working out whether $obj is a date
27
+		}
28
+		return $obj;
29
+	}
30 30
 
31 31
 	private function dateMatchesFormats($date, $str) {
32 32
 		foreach ($this->dateFormats as list($format, $len)) {
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 		return false;
36 36
 	}
37 37
 
38
-    private function isIterable($obj) {
39
-        return is_array($obj) || (is_object($obj) && ($obj instanceof \Iterator));
40
-    }
38
+	private function isIterable($obj) {
39
+		return is_array($obj) || (is_object($obj) && ($obj instanceof \Iterator));
40
+	}
41 41
 
42
-    private function isPossiblyDateString($obj) {
43
-        return is_string($obj) && isset($obj[0]) && is_numeric($obj[0]) && strlen($obj) <= 20;
44
-    }
42
+	private function isPossiblyDateString($obj) {
43
+		return is_string($obj) && isset($obj[0]) && is_numeric($obj[0]) && strlen($obj) <= 20;
44
+	}
45 45
 
46 46
 	private function checkCache($obj, $reset) {
47 47
 		if ($reset) $this->processCache = new \SplObjectStorage();
48
-        if (!is_object($obj)) return false;
48
+		if (!is_object($obj)) return false;
49 49
 
50 50
 		if ($this->processCache->contains($obj)) return $obj;
51 51
 		else $this->processCache->attach($obj, true);
Please login to merge, or discard this patch.
Maphper/Relation/One.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	private $siblings = [];
10 10
 
11 11
 	public function __construct(\Maphper\Maphper $mapper, $parentField, $localField, array $criteria = []) {
12
-        if ($criteria) $mapper = $mapper->filter($this->criteira);
12
+		if ($criteria) $mapper = $mapper->filter($this->criteira);
13 13
 		$this->mapper = $mapper;
14 14
 		$this->parentField = $parentField;
15 15
 		$this->localField = $localField;
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
 		//Fetch the results so they're in the cache for the corresponding maphper object
49 49
 		$results = $this->mapper->filter([$this->localField => $recordsToLoad]);
50 50
 
51
-        $this->loadDataIntoSiblings($results);
51
+		$this->loadDataIntoSiblings($results);
52 52
 	}
53 53
 
54
-    private function loadDataIntoSiblings($results) {
55
-        $cache = [];
54
+	private function loadDataIntoSiblings($results) {
55
+		$cache = [];
56 56
 		foreach ($results as $result) {
57 57
 			$cache[$result->{$this->localField}] = $result;
58 58
 		}
59 59
 
60 60
 		foreach ($this->siblings as $sibling) {
61
-            if (isset($cache[$sibling->parentObject->{$this->parentField}])) $sibling->data = $cache[$sibling->parentObject->{$this->parentField}];
61
+			if (isset($cache[$sibling->parentObject->{$this->parentField}])) $sibling->data = $cache[$sibling->parentObject->{$this->parentField}];
62 62
 		}
63 63
 		/*
64 64
 		foreach ($this->siblings as $sibling) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			else $sibling->data = $sibling->mapper->filter([$sibling->localField => $sibling->parentObject->{$this->parentField}])->item(0);
67 67
 		}
68 68
 		*/
69
-    }
69
+	}
70 70
 
71 71
 	public function __call($func, array $args = []) {
72 72
 		if ($this->lazyLoad() == null) return '';
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 	public function __get($name) {
77 77
 		if ($this->lazyLoad()) return $this->lazyLoad()->$name;
78
-        else return null;
78
+		else return null;
79 79
 	}
80 80
 
81 81
 	public function __isset($name) {
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 	public function overwrite($parentObject, &$data) {
86
-        $this->mapper[] = $data;
86
+		$this->mapper[] = $data;
87 87
 
88
-        if (!isset($parentObject->{$this->parentField}) || $parentObject->{$this->parentField} != $data->{$this->localField}) {
88
+		if (!isset($parentObject->{$this->parentField}) || $parentObject->{$this->parentField} != $data->{$this->localField}) {
89 89
 			$parentObject->{$this->parentField} = $data->{$this->localField};
90 90
 			//Trigger an update of the parent object
91 91
 			return true;
Please login to merge, or discard this patch.
Maphper/Relation/ManyManyIterator.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@
 block discarded – undo
7 7
   private $intermediateName;
8 8
 
9 9
   public function __construct(\Maphper\Iterator $iterator, $intermediateName = null) {
10
-    $this->iterator = $iterator;
11
-    $this->intermediateName = $intermediateName;
10
+	$this->iterator = $iterator;
11
+	$this->intermediateName = $intermediateName;
12 12
   }
13 13
 
14 14
   public function current() {
15
-    if ($this->intermediateName) return $this->iterator->current()->{$this->intermediateName};
15
+	if ($this->intermediateName) return $this->iterator->current()->{$this->intermediateName};
16 16
 		return $this->iterator->current();
17 17
 	}
18 18
 
19 19
 	public function key() {
20
-    return $this->iterator->key();
20
+	return $this->iterator->key();
21 21
 	}
22 22
 
23 23
 	public function next() {
Please login to merge, or discard this patch.
Maphper/Relation/ManyMany.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -88,25 +88,25 @@
 block discarded – undo
88 88
 		list($relatedField, $valueField, $mapper) = $this->getOtherFieldNameInfo();
89 89
 		if ($this->autoTraverse) $this->offsetSetAutotraverse($value, $relatedField, $valueField);
90 90
 		else if ($this->doUpdateInterMapper($value, $relatedField, $valueField)) {
91
-            $record = $value;
91
+			$record = $value;
92 92
 			$record->{$this->parentField} = $value->{$this->intermediateName}->{$this->localField};
93 93
 			$record->$valueField = $this->object->{$relatedField};
94 94
 			$this->intermediateMapper[] = $record;
95 95
 		}
96 96
 	}
97 97
 
98
-    private function doUpdateInterMapper($record, $relatedField, $valueField) {
99
-        return !(isset($record->{$this->parentField}) && isset($record->{$this->intermediateName}) &&
100
-                $record->{$this->parentField} == $record->{$this->intermediateName}->{$this->localField} &&
101
-                $record->$valueField == $this->object->{$relatedField});
102
-    }
103
-
104
-    private function offsetSetAutotraverse($value, $relatedField, $valueField) {
105
-        $record = new \stdClass;
106
-        $record->{$this->parentField} =  $value->{$this->localField};
107
-        $record->$valueField = $this->object->{$relatedField};
108
-        $this->intermediateMapper[] = $record;
109
-    }
98
+	private function doUpdateInterMapper($record, $relatedField, $valueField) {
99
+		return !(isset($record->{$this->parentField}) && isset($record->{$this->intermediateName}) &&
100
+				$record->{$this->parentField} == $record->{$this->intermediateName}->{$this->localField} &&
101
+				$record->$valueField == $this->object->{$relatedField});
102
+	}
103
+
104
+	private function offsetSetAutotraverse($value, $relatedField, $valueField) {
105
+		$record = new \stdClass;
106
+		$record->{$this->parentField} =  $value->{$this->localField};
107
+		$record->$valueField = $this->object->{$relatedField};
108
+		$this->intermediateMapper[] = $record;
109
+	}
110 110
 
111 111
 	public function offsetUnset($id) {
112 112
 		//$this->relation->mapper->filter([$relatedField => $this->object->$valueField, $this->relation->parentField => $id])->delete();
Please login to merge, or discard this patch.
Maphper/Maphper.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		$value = $this->entity->wrap($this->relations, $value);
97 97
 		$this->dataSource->save($value);
98 98
 		$visibilityOverride->write($value);
99
-        $this->entity->create((array_merge((array)$value, (array)$valueCopy)), $this->relations);
99
+		$this->entity->create((array_merge((array)$value, (array)$valueCopy)), $this->relations);
100 100
 	}
101 101
 
102 102
 	private function removeRelations($obj, $pk) { // Prevent saving ManyMany twice except when pk isn't initially set
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 
108 108
 	public function offsetExists($offset) {
109 109
 		if (count($this->dataSource->getPrimaryKey()) > 1) return new MultiPk($this, $offset, $this->dataSource->getPrimaryKey());
110
-        if (!empty($this->settings['filter'])) {
111
-            $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset]));
112
-            return isset($data[0]);
113
-        }
110
+		if (!empty($this->settings['filter'])) {
111
+			$data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset]));
112
+			return isset($data[0]);
113
+		}
114 114
 		return (bool) $this->dataSource->findById($offset);
115 115
 	}
116 116
 
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 
121 121
 	public function offsetGet($offset) {
122 122
 		if (count($this->dataSource->getPrimaryKey()) > 1) return new MultiPk($this, $offset, $this->dataSource->getPrimaryKey());
123
-        if (!empty($this->settings['filter'])) {
124
-            $data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset]));
125
-            return $this->entity->create(isset($data[0]) ? $data[0] : null, $this->relations);
126
-        }
123
+		if (!empty($this->settings['filter'])) {
124
+			$data = $this->dataSource->findByField(array_merge($this->settings['filter'], [$this->dataSource->getPrimaryKey()[0] => $offset]));
125
+			return $this->entity->create(isset($data[0]) ? $data[0] : null, $this->relations);
126
+		}
127 127
 		return $this->entity->create($this->dataSource->findById($offset), $this->relations);
128 128
 	}
129 129
 
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,22 +2,22 @@
 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);
9
+	public function getSql($key, $value, $mode) {
10
+		$args = [];
11
+		$inSql = [];
12
+		$count = count($value);
13 13
 		$value = array_values($value); // fix numeric index being different than $i
14
-        for ($i = 0; $i < $count; $i++) {
15
-            $args[$key . $i] = $value[$i];
16
-            $inSql[] = ':' . $key . $i;
17
-        }
18
-        if (count($inSql) == 0) return [];
19
-        else $sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
14
+		for ($i = 0; $i < $count; $i++) {
15
+			$args[$key . $i] = $value[$i];
16
+			$inSql[] = ':' . $key . $i;
17
+		}
18
+		if (count($inSql) == 0) return [];
19
+		else $sql = [$key . ' IN ( ' .  implode(', ', $inSql) . ')'];
20 20
 
21
-        return ['args' => $args, 'sql' => $sql];
22
-    }
21
+		return ['args' => $args, 'sql' => $sql];
22
+	}
23 23
 }
Please login to merge, or discard this patch.