@@ -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 | |
@@ -159,10 +159,10 @@ |
||
| 159 | 159 | public function newEntity(array $data): EntityInterface |
| 160 | 160 | { |
| 161 | 161 | $entity = $this->getHydrator() |
| 162 | - ->hydrate(array_merge( |
|
| 163 | - $this->getConfig()->getDefaultEntityAttributes(), |
|
| 164 | - $data |
|
| 165 | - )); |
|
| 162 | + ->hydrate(array_merge( |
|
| 163 | + $this->getConfig()->getDefaultEntityAttributes(), |
|
| 164 | + $data |
|
| 165 | + )); |
|
| 166 | 166 | |
| 167 | 167 | return $this->behaviours->apply($this, __FUNCTION__, $entity); |
| 168 | 168 | } |
@@ -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 | } |
@@ -65,86 +65,86 @@ |
||
| 65 | 65 | public static function varchar(string $name, $length = 255) |
| 66 | 66 | { |
| 67 | 67 | return static::make($name) |
| 68 | - ->setType(static::TYPE_VARCHAR) |
|
| 69 | - ->setLength($length); |
|
| 68 | + ->setType(static::TYPE_VARCHAR) |
|
| 69 | + ->setLength($length); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public static function bool(string $name) |
| 73 | 73 | { |
| 74 | 74 | return static::make($name) |
| 75 | - ->setType(static::TYPE_BOOLEAN); |
|
| 75 | + ->setType(static::TYPE_BOOLEAN); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public static function string(string $name) |
| 79 | 79 | { |
| 80 | 80 | return static::make($name) |
| 81 | - ->setType(static::TYPE_TEXT); |
|
| 81 | + ->setType(static::TYPE_TEXT); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public static function datetime(string $name) |
| 85 | 85 | { |
| 86 | 86 | return static::make($name) |
| 87 | - ->setType(static::TYPE_DATETIME); |
|
| 87 | + ->setType(static::TYPE_DATETIME); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | public static function date(string $name) |
| 91 | 91 | { |
| 92 | 92 | return static::make($name) |
| 93 | - ->setType(static::TYPE_DATE); |
|
| 93 | + ->setType(static::TYPE_DATE); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public static function timestamp(string $name) |
| 97 | 97 | { |
| 98 | 98 | return static::make($name) |
| 99 | - ->setType(static::TYPE_TIMESTAMP); |
|
| 99 | + ->setType(static::TYPE_TIMESTAMP); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public static function json(string $name) |
| 103 | 103 | { |
| 104 | 104 | return static::make($name) |
| 105 | - ->setType(static::TYPE_JSON); |
|
| 105 | + ->setType(static::TYPE_JSON); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public static function float(string $name) |
| 109 | 109 | { |
| 110 | 110 | return static::make($name) |
| 111 | - ->setType(static::TYPE_FLOAT); |
|
| 111 | + ->setType(static::TYPE_FLOAT); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public static function integer(string $name, $unsigned = false) |
| 115 | 115 | { |
| 116 | 116 | return static::make($name) |
| 117 | - ->setType(static::TYPE_INTEGER) |
|
| 118 | - ->setUnsigned($unsigned); |
|
| 117 | + ->setType(static::TYPE_INTEGER) |
|
| 118 | + ->setUnsigned($unsigned); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public static function tinyInteger(string $name, $unsigned = false) |
| 122 | 122 | { |
| 123 | 123 | return static::make($name) |
| 124 | - ->setType(static::TYPE_TINY_INTEGER) |
|
| 125 | - ->setUnsigned($unsigned); |
|
| 124 | + ->setType(static::TYPE_TINY_INTEGER) |
|
| 125 | + ->setUnsigned($unsigned); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public static function smallInteger(string $name, $unsigned = false) |
| 129 | 129 | { |
| 130 | 130 | return static::make($name) |
| 131 | - ->setType(static::TYPE_SMALL_INTEGER) |
|
| 132 | - ->setUnsigned($unsigned); |
|
| 131 | + ->setType(static::TYPE_SMALL_INTEGER) |
|
| 132 | + ->setUnsigned($unsigned); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | public static function bigInteger(string $name, $unsigned = false) |
| 136 | 136 | { |
| 137 | 137 | return static::make($name) |
| 138 | - ->setType(static::TYPE_BIG_INTEGER) |
|
| 139 | - ->setUnsigned($unsigned); |
|
| 138 | + ->setType(static::TYPE_BIG_INTEGER) |
|
| 139 | + ->setUnsigned($unsigned); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public static function decimal(string $name, int $digits, int $precision) |
| 143 | 143 | { |
| 144 | 144 | return static::make($name) |
| 145 | - ->setType(static::TYPE_DECIMAL) |
|
| 146 | - ->setDigits($digits) |
|
| 147 | - ->setPrecision($precision); |
|
| 145 | + ->setType(static::TYPE_DECIMAL) |
|
| 146 | + ->setDigits($digits) |
|
| 147 | + ->setPrecision($precision); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -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); |