Passed
Push — master ( 509b8c...0b1212 )
by Richard
01:44
created
maphper/relation/manymany.php 3 patches
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.
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
 		}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
     private function offsetSetAutotraverse($value, $relatedField, $valueField) {
105 105
         $record = new \stdClass;
106
-        $record->{$this->parentField} =  $value->{$this->localField};
106
+        $record->{$this->parentField} = $value->{$this->localField};
107 107
         $record->$valueField = $this->object->{$relatedField};
108 108
         $this->intermediateMapper[] = $record;
109 109
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 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.
@@ -86,8 +88,9 @@  discard block
 block discarded – undo
86 88
 
87 89
 	public function offsetSet($name, $value) {
88 90
 		list($relatedField, $valueField, $mapper) = $this->getOtherFieldNameInfo();
89
-		if ($this->autoTraverse) $this->offsetSetAutotraverse($value, $relatedField, $valueField);
90
-		else if ($this->doUpdateInterMapper($value, $relatedField, $valueField)) {
91
+		if ($this->autoTraverse) {
92
+			$this->offsetSetAutotraverse($value, $relatedField, $valueField);
93
+		} else if ($this->doUpdateInterMapper($value, $relatedField, $valueField)) {
91 94
             $record = $value;
92 95
 			$record->{$this->parentField} = $value->{$this->intermediateName}->{$this->localField};
93 96
 			$record->$valueField = $this->object->{$relatedField};
Please login to merge, or discard this patch.
maphper/relation/one.php 2 patches
Indentation   +6 added lines, -6 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,11 +48,11 @@  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
 		}
@@ -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) {
Please login to merge, or discard this patch.
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  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) {
13
+        	$mapper = $mapper->filter($this->criteira);
14
+        }
13 15
 		$this->mapper = $mapper;
14 16
 		$this->parentField = $parentField;
15 17
 		$this->localField = $localField;
@@ -29,7 +31,9 @@  discard block
 block discarded – undo
29 31
 	private function lazyLoad() {
30 32
 		if (!isset($this->data)) {
31 33
 
32
-			if ($this->parentObject == null) throw new \Exception('Error, no object set');
34
+			if ($this->parentObject == null) {
35
+				throw new \Exception('Error, no object set');
36
+			}
33 37
 
34 38
 			$this->eagerLoad();
35 39
 
@@ -69,13 +73,18 @@  discard block
 block discarded – undo
69 73
     }
70 74
 
71 75
 	public function __call($func, array $args = []) {
72
-		if ($this->lazyLoad() == null) return '';
76
+		if ($this->lazyLoad() == null) {
77
+			return '';
78
+		}
73 79
 		return call_user_func_array([$this->lazyLoad(), $func], $args);
74 80
 	}
75 81
 
76 82
 	public function __get($name) {
77
-		if ($this->lazyLoad()) return $this->lazyLoad()->$name;
78
-        else return null;
83
+		if ($this->lazyLoad()) {
84
+			return $this->lazyLoad()->$name;
85
+		} else {
86
+        	return null;
87
+        }
79 88
 	}
80 89
 
81 90
 	public function __isset($name) {
Please login to merge, or discard this patch.
maphper/datasource/mysqladapter.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 class MysqlAdapter implements DatabaseAdapter {
4 4
 	private $pdo;
5 5
 	private $stmtCache;
6
-    private $generalEditor;
6
+	private $generalEditor;
7 7
 
8 8
 	public function __construct(\PDO $pdo) {
9 9
 		$this->pdo = $pdo;
10 10
 		//Set to strict mode to detect 'out of range' errors, action at a distance but it needs to be set for all INSERT queries
11 11
 		$this->pdo->query('SET sql_mode = STRICT_ALL_TABLES');
12
-        $this->stmtCache = new StmtCache($pdo);
13
-        $this->generalEditor = new GeneralEditDatabase($this->pdo, ['short_string_max_len' => 191]);
12
+		$this->stmtCache = new StmtCache($pdo);
13
+		$this->generalEditor = new GeneralEditDatabase($this->pdo, ['short_string_max_len' => 191]);
14 14
 	}
15 15
 
16 16
 	public function quote($str) {
@@ -20,32 +20,32 @@  discard block
 block discarded – undo
20 20
 	public function query(\Maphper\Lib\Query $query) {
21 21
 		$stmt = $this->stmtCache->getCachedStmt($query->getSql());
22 22
 		$args = $query->getArgs();
23
-        $stmt->execute($args);
23
+		$stmt->execute($args);
24 24
 
25 25
 		return $stmt;
26 26
 	}
27 27
 
28
-    private function alterColumns($table, array $primaryKey, $data) {
29
-        foreach ($data as $key => $value) {
28
+	private function alterColumns($table, array $primaryKey, $data) {
29
+		foreach ($data as $key => $value) {
30 30
 			if ($this->generalEditor->isNotSavableType($value, $key, $primaryKey)) continue;
31 31
             
32 32
 			$type = $this->generalEditor->getType($value);
33 33
 			$this->tryAlteringColumn($table, $key, $type);
34 34
 		}
35
-    }
35
+	}
36 36
 
37
-    private function tryAlteringColumn($table, $key, $type) {
38
-        try {
39
-            if (!$this->pdo->query('ALTER TABLE ' . $table . ' ADD ' . $this->quote($key) . ' ' . $type)) throw new \Exception('Could not alter table');
40
-        }
41
-        catch (\Exception $e) {
42
-            $this->pdo->query('ALTER TABLE ' . $table . ' MODIFY ' . $this->quote($key) . ' ' . $type);
43
-        }
44
-    }
37
+	private function tryAlteringColumn($table, $key, $type) {
38
+		try {
39
+			if (!$this->pdo->query('ALTER TABLE ' . $table . ' ADD ' . $this->quote($key) . ' ' . $type)) throw new \Exception('Could not alter table');
40
+		}
41
+		catch (\Exception $e) {
42
+			$this->pdo->query('ALTER TABLE ' . $table . ' MODIFY ' . $this->quote($key) . ' ' . $type);
43
+		}
44
+	}
45 45
 
46 46
 	public function alterDatabase($table, array $primaryKey, $data) {
47 47
 		$this->generalEditor->createTable($table, $primaryKey, $data);
48
-        $this->alterColumns($table, $primaryKey, $data);
48
+		$this->alterColumns($table, $primaryKey, $data);
49 49
 	}
50 50
 
51 51
 	public function lastInsertId() {
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 
28 28
     private function alterColumns($table, array $primaryKey, $data) {
29 29
         foreach ($data as $key => $value) {
30
-			if ($this->generalEditor->isNotSavableType($value, $key, $primaryKey)) continue;
30
+			if ($this->generalEditor->isNotSavableType($value, $key, $primaryKey)) {
31
+				continue;
32
+			}
31 33
             
32 34
 			$type = $this->generalEditor->getType($value);
33 35
 			$this->tryAlteringColumn($table, $key, $type);
@@ -36,9 +38,10 @@  discard block
 block discarded – undo
36 38
 
37 39
     private function tryAlteringColumn($table, $key, $type) {
38 40
         try {
39
-            if (!$this->pdo->query('ALTER TABLE ' . $table . ' ADD ' . $this->quote($key) . ' ' . $type)) throw new \Exception('Could not alter table');
40
-        }
41
-        catch (\Exception $e) {
41
+            if (!$this->pdo->query('ALTER TABLE ' . $table . ' ADD ' . $this->quote($key) . ' ' . $type)) {
42
+            	throw new \Exception('Could not alter table');
43
+            }
44
+        } catch (\Exception $e) {
42 45
             $this->pdo->query('ALTER TABLE ' . $table . ' MODIFY ' . $this->quote($key) . ' ' . $type);
43 46
         }
44 47
     }
@@ -60,7 +63,9 @@  discard block
 block discarded – undo
60 63
 		$keyName = $this->quote(implode('_', $fields));
61 64
 
62 65
 		$results = $this->pdo->query('SHOW INDEX FROM ' . $this->quote($table) . ' WHERE Key_Name = "' . $keyName . '"');
63
-		if ($results && count($results->fetchAll()) == 0)  $this->pdo->query('CREATE INDEX ' . $keyName . ' ON ' . $this->quote($table) . ' (' . implode(', ', $fields) . ')');
66
+		if ($results && count($results->fetchAll()) == 0) {
67
+			$this->pdo->query('CREATE INDEX ' . $keyName . ' ON ' . $this->quote($table) . ' (' . implode(', ', $fields) . ')');
68
+		}
64 69
 	}
65 70
 
66 71
 	public function optimiseColumns($table) {
Please login to merge, or discard this patch.