Passed
Branch master (cd5206)
by Tom
02:53 queued 58s
created
maphper/multipk.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 	}
25 25
 
26 26
 	public function offsetGet($key) {
27
-		$depth = $this->getDepth()+1;
28
-		if (count($this->primaryKey)-1 == $depth) return $this->mapper->filter([$this->primaryKey[$depth] => $key])->item(0);
27
+		$depth = $this->getDepth() + 1;
28
+		if (count($this->primaryKey) - 1 == $depth) return $this->mapper->filter([$this->primaryKey[$depth] => $key])->item(0);
29 29
 		else return new MultiPk($this->mapper, $key, $this->primaryKey, $this);
30 30
 	}
31 31
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 	public function offsetUnset($key) {
46 46
 		$keys = $this->primaryKey;
47
-		$this->mapper->filter([ array_pop($keys) => $key])->delete();
47
+		$this->mapper->filter([array_pop($keys) => $key])->delete();
48 48
 	}
49 49
 
50 50
 	public function offsetExists($key) {
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,11 @@
 block discarded – undo
25 25
 
26 26
 	public function offsetGet($key) {
27 27
 		$depth = $this->getDepth()+1;
28
-		if (count($this->primaryKey)-1 == $depth) return $this->mapper->filter([$this->primaryKey[$depth] => $key])->item(0);
29
-		else return new MultiPk($this->mapper, $key, $this->primaryKey, $this);
28
+		if (count($this->primaryKey)-1 == $depth) {
29
+			return $this->mapper->filter([$this->primaryKey[$depth] => $key])->item(0);
30
+		} else {
31
+			return new MultiPk($this->mapper, $key, $this->primaryKey, $this);
32
+		}
30 33
 	}
31 34
 
32 35
 	public function offsetSet($key, $value) {
Please login to merge, or discard this patch.
maphper/relation/many.php 1 patch
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	private $localField;
7 7
 	
8 8
 	public function __construct(\Maphper\Maphper $mapper, $parentField, $localField, array $critiera = []) {
9
-		if ($critiera) $mapper->filter($critiera);
9
+		if ($critiera) {
10
+			$mapper->filter($critiera);
11
+		}
10 12
 		$this->mapper = $mapper;
11 13
 		$this->parentField = $parentField;
12 14
 		$this->localField = $localField;		
@@ -14,17 +16,24 @@  discard block
 block discarded – undo
14 16
 	
15 17
 	
16 18
 	public function getData($parentObject) {
17
-		if (!isset($parentObject->{$this->parentField})) $mapper = $this->mapper;
18
-		else $mapper = $this->mapper->filter([$this->localField => $parentObject->{$this->parentField}]);
19
+		if (!isset($parentObject->{$this->parentField})) {
20
+			$mapper = $this->mapper;
21
+		} else {
22
+			$mapper = $this->mapper->filter([$this->localField => $parentObject->{$this->parentField}]);
23
+		}
19 24
 		
20 25
 		return $mapper;
21 26
 	}
22 27
 
23 28
 	
24 29
 	public function overwrite($key, &$mapper) {
25
-		if (!isset($key->{$this->parentField})) return false;
30
+		if (!isset($key->{$this->parentField})) {
31
+			return false;
32
+		}
26 33
 		foreach ($mapper as $k => $val) {
27
-			if (!empty($val->{$this->localField}) && $val->{$this->localField} == $key->{$this->parentField}) continue;
34
+			if (!empty($val->{$this->localField}) && $val->{$this->localField} == $key->{$this->parentField}) {
35
+				continue;
36
+			}
28 37
 			$val->{$this->localField} = $key->{$this->parentField};
29 38
 			$this->mapper[] = $val;
30 39
 		}
Please login to merge, or discard this patch.
maphper/relation/manymany.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	//bit hacky, breaking encapsulation, but simplest way to work out the info for the other side of the many:many relationship.
38 38
 	private function getOtherFieldNameInfo() {
39 39
 		if ($this->otherInfo == null) {
40
-			$propertyReader = function($name) {return $this->$name;	};
40
+			$propertyReader = function($name) {return $this->$name; };
41 41
 
42 42
 			$reader = $propertyReader->bindTo($this->intermediateMapper, $this->intermediateMapper);
43 43
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 				$propertyReader = $propertyReader->bindTo($relation, $relation);
46 46
 				if ($propertyReader('parentField') != $this->parentField) {
47 47
 					$relation = $relation->getData($this->object);
48
-					$this->otherInfo = [$propertyReader('localField'),  $propertyReader('parentField'), $propertyReader('mapper')];
48
+					$this->otherInfo = [$propertyReader('localField'), $propertyReader('parentField'), $propertyReader('mapper')];
49 49
 				}
50 50
 			}
51 51
 		}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		list($relatedField, $valueField, $mapper) = $this->getOtherFieldNameInfo();
89 89
 		if ($this->autoTraverse) {
90 90
 			$record = new \stdClass;
91
-			$record->{$this->parentField} =  $value->{$this->localField};
91
+			$record->{$this->parentField} = $value->{$this->localField};
92 92
 			$record->$valueField = $this->object->{$relatedField};
93 93
 			$this->intermediateMapper[] = $record;
94 94
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 	public function overwrite($parentObject, &$data) {
32 32
 		$this->results = $data;
33 33
 		$this->object = $parentObject;
34
-		foreach ($data as $dt) $this[] = $dt;
34
+		foreach ($data as $dt) {
35
+			$this[] = $dt;
36
+		}
35 37
 	}
36 38
 
37 39
 	//bit hacky, breaking encapsulation, but simplest way to work out the info for the other side of the many:many relationship.
@@ -92,15 +94,13 @@  discard block
 block discarded – undo
92 94
 			$record->$valueField = $this->object->{$relatedField};
93 95
 			$this->intermediateMapper[] = $record;
94 96
 
95
-		}
96
-		else {
97
+		} else {
97 98
 			$record = $value;
98 99
 			if (isset($record->{$this->parentField}) && isset($value->{$this->intermediateName}) &&
99 100
 					$record->{$this->parentField} == $value->{$this->intermediateName}->{$this->localField} &&
100 101
 					$record->$valueField == $this->object->{$relatedField}) {
101 102
 				return;
102
-			}
103
-			else {
103
+			} else {
104 104
 				$record->{$this->parentField} = $value->{$this->intermediateName}->{$this->localField};
105 105
 				$record->$valueField = $this->object->{$relatedField};
106 106
 				$this->intermediateMapper[] = $record;
Please login to merge, or discard this patch.
maphper/relation/one.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 
75 75
 	public function __get($name) {
76 76
 		if ($this->lazyLoad()) return $this->lazyLoad()->$name;
77
-        else return null;
77
+		else return null;
78 78
 	}
79 79
 
80 80
 	public function __isset($name) {
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
 	private function lazyLoad() {
31 31
 		if (!isset($this->data)) {
32 32
 
33
-			if ($this->parentObject == null) throw new \Exception('Error, no object set');
33
+			if ($this->parentObject == null) {
34
+				throw new \Exception('Error, no object set');
35
+			}
34 36
 
35 37
 			$this->eagerLoad();
36 38
 			
@@ -47,8 +49,11 @@  discard block
 block discarded – undo
47 49
 
48 50
 		$recordsToLoad = array_unique($recordsToLoad);
49 51
 		//Fetch the results so they're in the cache for the corresponding maphper object
50
-		if ($this->criteria) $results = $this->mapper->filter($this->criteira)->filter([$this->localField => $recordsToLoad]);
51
-		else $results = $this->mapper->filter([$this->localField => $recordsToLoad]);
52
+		if ($this->criteria) {
53
+			$results = $this->mapper->filter($this->criteira)->filter([$this->localField => $recordsToLoad]);
54
+		} else {
55
+			$results = $this->mapper->filter([$this->localField => $recordsToLoad]);
56
+		}
52 57
 			
53 58
 		$cache = [];
54 59
 		foreach ($results as $result) {
@@ -68,13 +73,18 @@  discard block
 block discarded – undo
68 73
 	}
69 74
 
70 75
 	public function __call($func, array $args = []) {
71
-		if ($this->lazyLoad() == null) return '';
76
+		if ($this->lazyLoad() == null) {
77
+			return '';
78
+		}
72 79
 		return call_user_func_array([$this->lazyLoad(), $func], $args);
73 80
 	}
74 81
 
75 82
 	public function __get($name) {
76
-		if ($this->lazyLoad()) return $this->lazyLoad()->$name;
77
-        else return null;
83
+		if ($this->lazyLoad()) {
84
+			return $this->lazyLoad()->$name;
85
+		} else {
86
+        	return null;
87
+        }
78 88
 	}
79 89
 
80 90
 	public function __isset($name) {
Please login to merge, or discard this patch.
maphper/relation/manymanyiterator.php 2 patches
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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@
 block discarded – undo
12 12
   }
13 13
 
14 14
   public function current() {
15
-    if ($this->intermediateName) return $this->iterator->current()->{$this->intermediateName};
15
+    if ($this->intermediateName) {
16
+    	return $this->iterator->current()->{$this->intermediateName};
17
+    }
16 18
 		return $this->iterator->current();
17 19
 	}
18 20
 
Please login to merge, or discard this patch.
maphper/lib/propertywriter.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@
 block discarded – undo
4 4
 	private $closure;
5 5
 	public function __construct($object) {
6 6
 		if ($object instanceof \stdclass) {
7
-			$this->closure = function ($field, $value) use ($object) { $object->$field = $value; };
7
+			$this->closure = function($field, $value) use ($object) { $object->$field = $value; };
8 8
 		}
9 9
 		else {
10
-			$this->closure = function ($field, $value) { $this->$field = $value; };
10
+			$this->closure = function($field, $value) { $this->$field = $value; };
11 11
 			$this->closure = $this->closure->bindTo($object, $object);
12 12
 		}
13 13
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 	public function __construct($object) {
6 6
 		if ($object instanceof \stdclass) {
7 7
 			$this->closure = function ($field, $value) use ($object) { $object->$field = $value; };
8
-		}
9
-		else {
8
+		} else {
10 9
 			$this->closure = function ($field, $value) { $this->$field = $value; };
11 10
 			$this->closure = $this->closure->bindTo($object, $object);
12 11
 		}
Please login to merge, or discard this patch.