@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * Class Entity |
| 58 | 58 | * @package Platine\Orm |
| 59 | 59 | */ |
| 60 | -abstract class Entity implements JsonSerializable |
|
| 61 | -{ |
|
| 60 | +abstract class Entity implements JsonSerializable { |
|
| 62 | 61 | /** |
| 63 | 62 | * The instance of data mapper |
| 64 | 63 | * @var DataMapper|null |
@@ -102,8 +101,7 @@ discard block |
||
| 102 | 101 | * Convert entity to JSON array |
| 103 | 102 | * @return array<string, mixed> |
| 104 | 103 | */ |
| 105 | - public function jsonSerialize() |
|
| 106 | - { |
|
| 104 | + public function jsonSerialize() { |
|
| 107 | 105 | $rawColumns = $this->mapper()->getRawColumns(); |
| 108 | 106 | $data = []; |
| 109 | 107 | foreach ($rawColumns as $name => $value) { |
@@ -124,8 +122,7 @@ discard block |
||
| 124 | 122 | * @param string $name |
| 125 | 123 | * @return mixed |
| 126 | 124 | */ |
| 127 | - public function __get(string $name) |
|
| 128 | - { |
|
| 125 | + public function __get(string $name) { |
|
| 129 | 126 | if ($this->mapper()->hasRelation($name)) { |
| 130 | 127 | return $this->mapper()->getRelated($name); |
| 131 | 128 | } |
@@ -146,8 +143,7 @@ discard block |
||
| 146 | 143 | * @param mixed $value |
| 147 | 144 | * @return void |
| 148 | 145 | */ |
| 149 | - public function __set(string $name, $value) |
|
| 150 | - { |
|
| 146 | + public function __set(string $name, $value) { |
|
| 151 | 147 | if ($this->mapper()->hasRelation($name)) { |
| 152 | 148 | if (is_array($value)) { |
| 153 | 149 | foreach ($value as $entity) { |
@@ -166,8 +162,7 @@ discard block |
||
| 166 | 162 | * @param string $name |
| 167 | 163 | * @return bool |
| 168 | 164 | */ |
| 169 | - public function __isset(string $name) |
|
| 170 | - { |
|
| 165 | + public function __isset(string $name) { |
|
| 171 | 166 | return $this->mapper()->hasRelation($name) |
| 172 | 167 | || $this->mapper()->hasColumn($name); |
| 173 | 168 | } |
@@ -177,8 +172,7 @@ discard block |
||
| 177 | 172 | * @param string $name |
| 178 | 173 | * @return bool |
| 179 | 174 | */ |
| 180 | - public function __unset(string $name) |
|
| 181 | - { |
|
| 175 | + public function __unset(string $name) { |
|
| 182 | 176 | $this->mapper()->clearColumn($name, true); |
| 183 | 177 | } |
| 184 | 178 | |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - /** |
|
| 322 | - * {@inheritedoc} |
|
| 323 | - */ |
|
| 321 | + /** |
|
| 322 | + * {@inheritedoc} |
|
| 323 | + */ |
|
| 324 | 324 | public function hasColumn(string $column): bool |
| 325 | 325 | { |
| 326 | 326 | return array_key_exists($column, $this->columns) |
@@ -353,9 +353,9 @@ discard block |
||
| 353 | 353 | $this->rawColumns[$name] = $value; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * {@inheritedoc} |
|
| 358 | - */ |
|
| 356 | + /** |
|
| 357 | + * {@inheritedoc} |
|
| 358 | + */ |
|
| 359 | 359 | public function getRelated(string $name, callable $callback = null) |
| 360 | 360 | { |
| 361 | 361 | if (array_key_exists($name, $this->relations)) { |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $primaryKey = $this->mapper->getPrimaryKey(); |
| 262 | - if ($name === (string)$primaryKey) { |
|
| 262 | + if ($name === (string) $primaryKey) { |
|
| 263 | 263 | return $this->columns[$name] = $value; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | { |
| 314 | 314 | unset($this->columns[$name]); |
| 315 | 315 | |
| 316 | - if($raw){ |
|
| 316 | + if ($raw) { |
|
| 317 | 317 | unset($this->rawColumns[$name]); |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | * Class DataMapper |
| 68 | 68 | * @package Platine\Orm\Mapper |
| 69 | 69 | */ |
| 70 | -class DataMapper implements DataMapperInterface |
|
| 71 | -{ |
|
| 70 | +class DataMapper implements DataMapperInterface { |
|
| 72 | 71 | /** |
| 73 | 72 | * The raw columns data |
| 74 | 73 | * @var array<string, mixed> |
@@ -230,8 +229,7 @@ discard block |
||
| 230 | 229 | /** |
| 231 | 230 | * {@inheritedoc} |
| 232 | 231 | */ |
| 233 | - public function getColumn(string $name) |
|
| 234 | - { |
|
| 232 | + public function getColumn(string $name) { |
|
| 235 | 233 | if ($this->refresh) { |
| 236 | 234 | $this->hydrate(); |
| 237 | 235 | } |
@@ -313,7 +311,7 @@ discard block |
||
| 313 | 311 | { |
| 314 | 312 | unset($this->columns[$name]); |
| 315 | 313 | |
| 316 | - if($raw){ |
|
| 314 | + if($raw) { |
|
| 317 | 315 | unset($this->rawColumns[$name]); |
| 318 | 316 | } |
| 319 | 317 | } |
@@ -356,8 +354,7 @@ discard block |
||
| 356 | 354 | /** |
| 357 | 355 | * {@inheritedoc} |
| 358 | 356 | */ |
| 359 | - public function getRelated(string $name, callable $callback = null) |
|
| 360 | - { |
|
| 357 | + public function getRelated(string $name, callable $callback = null) { |
|
| 361 | 358 | if (array_key_exists($name, $this->relations)) { |
| 362 | 359 | return $this->relations[$name]; |
| 363 | 360 | } |
@@ -616,8 +613,7 @@ discard block |
||
| 616 | 613 | * |
| 617 | 614 | * @return mixed |
| 618 | 615 | */ |
| 619 | - protected function castGet($value, string $type) |
|
| 620 | - { |
|
| 616 | + protected function castGet($value, string $type) { |
|
| 621 | 617 | $original = $type; |
| 622 | 618 | |
| 623 | 619 | if ($type[0] === '?') { |
@@ -669,8 +665,7 @@ discard block |
||
| 669 | 665 | * |
| 670 | 666 | * @return mixed |
| 671 | 667 | */ |
| 672 | - protected function castSet($value, string $type) |
|
| 673 | - { |
|
| 668 | + protected function castSet($value, string $type) { |
|
| 674 | 669 | $original = $type; |
| 675 | 670 | |
| 676 | 671 | if ($type[0] === '?') { |