@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param class-string<T> $clss |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - public function __construct(DBInterface $db, string|Table $table = '', string $clss = Entity::class) |
|
| 28 | + public function __construct(DBInterface $db, string | Table $table = '', string $clss = Entity::class) |
|
| 29 | 29 | { |
| 30 | 30 | $this->db = $db; |
| 31 | 31 | if (!$table) { |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $lazy = []; |
| 113 | 113 | foreach ($this->table->getColumns() as $column) { |
| 114 | 114 | if (!array_key_exists($column, $temp)) { |
| 115 | - $lazy[$column] = function () use ($primary, $column) { |
|
| 115 | + $lazy[$column] = function() use ($primary, $column) { |
|
| 116 | 116 | $query = $this->db->table($this->table->getFullName()); |
| 117 | 117 | foreach ($primary as $k => $v) { |
| 118 | 118 | $query->filter($k, $v); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $relations = []; |
| 125 | 125 | foreach ($this->table->getRelations() as $name => $relation) { |
| 126 | 126 | $mapper = $this->db->getMapper($relation->table); |
| 127 | - $relations[$name] = function (bool $queryOnly = false) use ( |
|
| 127 | + $relations[$name] = function(bool $queryOnly = false) use ( |
|
| 128 | 128 | $name, |
| 129 | 129 | $relation, |
| 130 | 130 | $mapper, |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | ) { |
| 133 | 133 | if (!$queryOnly && isset($data[$name])) { |
| 134 | 134 | return $relation->many ? |
| 135 | - array_map(function ($v) use ($mapper) { |
|
| 135 | + array_map(function($v) use ($mapper) { |
|
| 136 | 136 | return $mapper->entity($v); |
| 137 | 137 | }, $data[$name]) : |
| 138 | 138 | $mapper->entity($data[$name]); |
| 139 | 139 | } |
| 140 | 140 | $query = $this->db->tableMapped($relation->table->getFullName()); |
| 141 | 141 | if ($relation->sql) { |
| 142 | - $query->where($relation->sql, $relation->par?:[]); |
|
| 142 | + $query->where($relation->sql, $relation->par ?: []); |
|
| 143 | 143 | } |
| 144 | 144 | if ($relation->pivot) { |
| 145 | 145 | $nm = null; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | ); |
| 160 | 160 | } |
| 161 | 161 | foreach ($this->table->getPrimaryKey() as $v) { |
| 162 | - $query->filter($nm . '.' . $v, $data[$v] ?? null); |
|
| 162 | + $query->filter($nm.'.'.$v, $data[$v] ?? null); |
|
| 163 | 163 | } |
| 164 | 164 | } else { |
| 165 | 165 | foreach ($relation->keymap as $k => $v) { |
@@ -170,8 +170,7 @@ discard block |
||
| 170 | 170 | return $query; |
| 171 | 171 | } |
| 172 | 172 | return $relation->many ? |
| 173 | - $query->iterator() : |
|
| 174 | - ($query[0] ?? null); |
|
| 173 | + $query->iterator() : ($query[0] ?? null); |
|
| 175 | 174 | }; |
| 176 | 175 | } |
| 177 | 176 | $entity = $this->instance($temp, $lazy, $relations); |