@@ -10,7 +10,7 @@ |
||
10 | 10 | public static function new(...$args) |
11 | 11 | { |
12 | 12 | if ($args[0] instanceof Connection) { |
13 | - return new ConnectionLocator(function () use ($args) { |
|
13 | + return new ConnectionLocator(function() use ($args) { |
|
14 | 14 | return $args[0]; |
15 | 15 | }); |
16 | 16 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | public static function getInstance() |
18 | 18 | { |
19 | - if ( ! static::$instance) { |
|
19 | + if (!static::$instance) { |
|
20 | 20 | static::$instance = new static; |
21 | 21 | } |
22 | 22 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | protected function getQueryClass(Mapper $mapper) |
34 | 34 | { |
35 | 35 | $mapperClass = get_class($mapper); |
36 | - if ( ! isset($this->queryClasses[$mapperClass])) { |
|
36 | + if (!isset($this->queryClasses[$mapperClass])) { |
|
37 | 37 | $queryClass = $mapperClass . 'Query'; |
38 | 38 | if (class_exists($queryClass)) { |
39 | 39 | $this->queryClasses[$mapperClass] = $queryClass; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function getTableAlias($fallbackToTable = false) |
151 | 151 | { |
152 | - return ( ! $this->tableAlias && $fallbackToTable) ? $this->table : $this->tableAlias; |
|
152 | + return (!$this->tableAlias && $fallbackToTable) ? $this->table : $this->tableAlias; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | public function getTableReference() |
221 | 221 | { |
222 | - if ( ! $this->tableReference) { |
|
222 | + if (!$this->tableReference) { |
|
223 | 223 | $this->tableReference = QueryHelper::reference($this->table, $this->tableAlias); |
224 | 224 | } |
225 | 225 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $mapper = new static($connectionLocator); |
60 | 60 | $mapper->mapperConfig = $mapperConfig; |
61 | 61 | |
62 | - if ( ! empty($mapperConfig->getBehaviours())) { |
|
62 | + if (!empty($mapperConfig->getBehaviours())) { |
|
63 | 63 | $mapper->use(...$mapperConfig->getBehaviours()); |
64 | 64 | } |
65 | 65 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | public function getRelation($name): Relation |
188 | 188 | { |
189 | - if ( ! $this->hasRelation($name)) { |
|
189 | + if (!$this->hasRelation($name)) { |
|
190 | 190 | throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper"); |
191 | 191 | } |
192 | 192 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $this->relations[$name] = $this->orm->createRelation($this, $name, $this->relations[$name]); |
195 | 195 | } |
196 | 196 | $relation = $this->relations[$name]; |
197 | - if ( ! $relation instanceof Relation) { |
|
197 | + if (!$relation instanceof Relation) { |
|
198 | 198 | throw new \InvalidArgumentException("Relation named {$name} is not a proper Relation instance"); |
199 | 199 | } |
200 | 200 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function underscore(string $str): string |
17 | 17 | { |
18 | - if ( ! isset(static::$cache['underscore'][$str])) { |
|
18 | + if (!isset(static::$cache['underscore'][$str])) { |
|
19 | 19 | $str = preg_replace("/([A-Z]+)/", ' $1', $str); |
20 | 20 | $str = strtolower($str); |
21 | 21 | $str = preg_replace("/[^a-z0-9]+/", ' ', $str); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public static function methodName(string $str, string $verb): string |
30 | 30 | { |
31 | 31 | $key = $verb . $str; |
32 | - if ( ! isset(static::$cache['methodName'][$key])) { |
|
32 | + if (!isset(static::$cache['methodName'][$key])) { |
|
33 | 33 | static::$cache['methodName'][$key] = strtolower($verb) . static::className($str); |
34 | 34 | } |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | public static function variableName(string $str): string |
40 | 40 | { |
41 | - if ( ! isset(static::$cache['variableName'][$str])) { |
|
41 | + if (!isset(static::$cache['variableName'][$str])) { |
|
42 | 42 | $class = static::className($str); |
43 | 43 | |
44 | 44 | static::$cache['variableName'][$str] = strtolower(substr($class, 0, 1)) . substr($class, 1); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public static function className(string $str): string |
51 | 51 | { |
52 | - if ( ! isset(static::$cache['className'][$str])) { |
|
52 | + if (!isset(static::$cache['className'][$str])) { |
|
53 | 53 | $str = strtolower($str); |
54 | 54 | $str = preg_replace("/[^a-z0-9]+/", ' ', $str); |
55 | 55 | $str = ucwords($str); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | { |
8 | 8 | public static function reference($table, $tableAlias) |
9 | 9 | { |
10 | - if ( ! $tableAlias || $table == $tableAlias) { |
|
10 | + if (!$tableAlias || $table == $tableAlias) { |
|
11 | 11 | return $table; |
12 | 12 | } |
13 | 13 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | if (strpos($key, $separator)) { |
27 | 27 | $parents = static::getParents($key, $separator); |
28 | 28 | foreach ($parents as $parent) { |
29 | - if ( ! isset($arr[$parent])) { |
|
29 | + if (!isset($arr[$parent])) { |
|
30 | 30 | $arr[$parent] = null; |
31 | 31 | } |
32 | 32 | } |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | { |
42 | 42 | $errors = []; |
43 | 43 | |
44 | - if ( ! $this->type) { |
|
44 | + if (!$this->type) { |
|
45 | 45 | $errors[] = "Uknown relation type"; |
46 | 46 | } |
47 | 47 | |
48 | - if ( ! $this->nativeKey) { |
|
48 | + if (!$this->nativeKey) { |
|
49 | 49 | $errors[] = "Missing native key column"; |
50 | 50 | } |
51 | 51 | |
52 | - if ( ! $this->foreignMapper) { |
|
52 | + if (!$this->foreignMapper) { |
|
53 | 53 | $errors[] = "Missing foreign mapper name"; |
54 | 54 | } |
55 | 55 | |
56 | - if ( ! $this->foreignKey) { |
|
56 | + if (!$this->foreignKey) { |
|
57 | 57 | $errors[] = "Missing foreign key"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $strategies = [RelationConfig::LOAD_LAZY, RelationConfig::LOAD_EAGER, RelationConfig::LOAD_NONE]; |
61 | - if ( ! in_array($this->loadStrategy, $strategies)) { |
|
61 | + if (!in_array($this->loadStrategy, $strategies)) { |
|
62 | 62 | $errors[] = sprintf("Relation loading strategy is not valid (allowed values: %s)", implode(', ', $strategies)); |
63 | 63 | } |
64 | 64 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | public function toArray() { |
189 | 189 | $result = []; |
190 | - foreach(get_object_vars($this) as $prop => $value) { |
|
190 | + foreach (get_object_vars($this) as $prop => $value) { |
|
191 | 191 | if (in_array($prop, ['mapper'])) { |
192 | 192 | continue; |
193 | 193 | } |
@@ -152,11 +152,11 @@ |
||
152 | 152 | { |
153 | 153 | $errors = []; |
154 | 154 | |
155 | - if ( ! $this->name) { |
|
155 | + if (!$this->name) { |
|
156 | 156 | $errors[] = 'Column requires a name'; |
157 | 157 | } |
158 | 158 | |
159 | - if ( ! $this->type) { |
|
159 | + if (!$this->type) { |
|
160 | 160 | $errors[] = 'Column requires a type'; |
161 | 161 | } elseif (($type = $this->getConstantByValue($this->type)) && substr($type, 0, 5) !== 'TYPE_') { |
162 | 162 | $errors[] = sprintf('Column does not have a valid type (%s)', $this->type); |