@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * @package Platine\Orm\Relation |
| 56 | 56 | * @template TEntity as Entity |
| 57 | 57 | */ |
| 58 | -class PrimaryKey |
|
| 59 | -{ |
|
| 58 | +class PrimaryKey { |
|
| 60 | 59 | /** |
| 61 | 60 | * |
| 62 | 61 | * @var array<int, string> |
@@ -73,8 +72,7 @@ discard block |
||
| 73 | 72 | * Create new instance |
| 74 | 73 | * @param string ...$columns |
| 75 | 74 | */ |
| 76 | - public function __construct(string ...$columns) |
|
| 77 | - { |
|
| 75 | + public function __construct(string ...$columns) { |
|
| 78 | 76 | $this->columns = $columns; |
| 79 | 77 | $this->composite = count($columns) > 1; |
| 80 | 78 | } |
@@ -104,8 +102,7 @@ discard block |
||
| 104 | 102 | * |
| 105 | 103 | * @return mixed|array<string, mixed>|null |
| 106 | 104 | */ |
| 107 | - public function getValue(array $columns, bool $map = false) |
|
| 108 | - { |
|
| 105 | + public function getValue(array $columns, bool $map = false) { |
|
| 109 | 106 | if (!$this->composite && !$map) { |
| 110 | 107 | return isset($columns[$this->columns[0]]) |
| 111 | 108 | ? $columns[$this->columns[0]] |
@@ -130,8 +127,7 @@ discard block |
||
| 130 | 127 | * |
| 131 | 128 | * @return mixed|array<string, mixed>|null |
| 132 | 129 | */ |
| 133 | - public function getValueFromDataMapper(DataMapper $mapper, bool $map = false) |
|
| 134 | - { |
|
| 130 | + public function getValueFromDataMapper(DataMapper $mapper, bool $map = false) { |
|
| 135 | 131 | return $this->getValue($mapper->getRawColumns(), $map); |
| 136 | 132 | } |
| 137 | 133 | |
@@ -141,8 +137,7 @@ discard block |
||
| 141 | 137 | * @param bool $map |
| 142 | 138 | * @return mixed|array<string, mixed>|null |
| 143 | 139 | */ |
| 144 | - public function getValueFromEntity(Entity $entity, bool $map = false) |
|
| 145 | - { |
|
| 140 | + public function getValueFromEntity(Entity $entity, bool $map = false) { |
|
| 146 | 141 | $columns = Proxy::instance()->getEntityColumns($entity); |
| 147 | 142 | return $this->getValue($columns, $map); |
| 148 | 143 | } |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | * @class ForeignKey |
| 51 | 51 | * @package Platine\Orm\Relation |
| 52 | 52 | */ |
| 53 | -class ForeignKey |
|
| 54 | -{ |
|
| 53 | +class ForeignKey { |
|
| 55 | 54 | /** |
| 56 | 55 | * |
| 57 | 56 | * @var array<string, string> |
@@ -68,8 +67,7 @@ discard block |
||
| 68 | 67 | * Create new instance |
| 69 | 68 | * @param array<string, string> $columns |
| 70 | 69 | */ |
| 71 | - public function __construct(array $columns) |
|
| 72 | - { |
|
| 70 | + public function __construct(array $columns) { |
|
| 73 | 71 | $this->columns = $columns; |
| 74 | 72 | $this->composite = count($columns) > 1; |
| 75 | 73 | } |
@@ -99,8 +97,7 @@ discard block |
||
| 99 | 97 | * |
| 100 | 98 | * @return mixed|array<string, mixed>|null |
| 101 | 99 | */ |
| 102 | - public function getValue(array $columns, bool $map = false) |
|
| 103 | - { |
|
| 100 | + public function getValue(array $columns, bool $map = false) { |
|
| 104 | 101 | if (!$map && !$this->composite) { |
| 105 | 102 | $column = array_keys($this->columns); |
| 106 | 103 | |
@@ -127,8 +124,7 @@ discard block |
||
| 127 | 124 | * |
| 128 | 125 | * @return mixed|array<string, mixed>|null |
| 129 | 126 | */ |
| 130 | - public function getInverseValue(array $columns, bool $map = false) |
|
| 131 | - { |
|
| 127 | + public function getInverseValue(array $columns, bool $map = false) { |
|
| 132 | 128 | if (!$map && !$this->composite) { |
| 133 | 129 | $column = array_values($this->columns); |
| 134 | 130 | |
@@ -154,8 +150,7 @@ discard block |
||
| 154 | 150 | * |
| 155 | 151 | * @return mixed|array<string, mixed>|null |
| 156 | 152 | */ |
| 157 | - public function extractValue(array $columns, bool $map = false) |
|
| 158 | - { |
|
| 153 | + public function extractValue(array $columns, bool $map = false) { |
|
| 159 | 154 | if (!$map && !$this->composite) { |
| 160 | 155 | $column = array_values($this->columns); |
| 161 | 156 | |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * @package Platine\Orm |
| 59 | 59 | * @template TEntity as Entity |
| 60 | 60 | */ |
| 61 | -class EntityManager |
|
| 62 | -{ |
|
| 61 | +class EntityManager { |
|
| 63 | 62 | /** |
| 64 | 63 | * The connection |
| 65 | 64 | * @var Connection |
@@ -82,8 +81,7 @@ discard block |
||
| 82 | 81 | * Create new instance |
| 83 | 82 | * @param Connection $connection |
| 84 | 83 | */ |
| 85 | - public function __construct(Connection $connection) |
|
| 86 | - { |
|
| 84 | + public function __construct(Connection $connection) { |
|
| 87 | 85 | $this->connection = $connection; |
| 88 | 86 | $this->dateFormat = $connection->getDriver()->getDateFormat(); |
| 89 | 87 | } |
@@ -199,9 +199,9 @@ |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * Map the entity information |
|
| 203 | - * @param EntityMapperInterface<TEntity> $mapper |
|
| 204 | - */ |
|
| 202 | + * Map the entity information |
|
| 203 | + * @param EntityMapperInterface<TEntity> $mapper |
|
| 204 | + */ |
|
| 205 | 205 | abstract public static function mapEntity(EntityMapperInterface $mapper): void; |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | foreach ($rawColumns as $name => $value) { |
| 111 | 111 | if ($this->mapper()->hasRelation($name)) { |
| 112 | 112 | $relation = $this->mapper()->getRelated($name); |
| 113 | - if($relation instanceof self){ |
|
| 113 | + if ($relation instanceof self) { |
|
| 114 | 114 | $data[$name] = $relation->jsonSerialize(); |
| 115 | 115 | } else { |
| 116 | 116 | $data[$name] = $relation; |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * @package Platine\Orm |
| 59 | 59 | * @template TEntity as Entity |
| 60 | 60 | */ |
| 61 | -abstract class Entity implements JsonSerializable |
|
| 62 | -{ |
|
| 61 | +abstract class Entity implements JsonSerializable { |
|
| 63 | 62 | /** |
| 64 | 63 | * The instance of data mapper |
| 65 | 64 | * @var DataMapper<TEntity> |null |
@@ -103,14 +102,13 @@ discard block |
||
| 103 | 102 | * Convert entity to JSON array |
| 104 | 103 | * @return array<string, mixed> |
| 105 | 104 | */ |
| 106 | - public function jsonSerialize() |
|
| 107 | - { |
|
| 105 | + public function jsonSerialize() { |
|
| 108 | 106 | $rawColumns = $this->mapper()->getRawColumns(); |
| 109 | 107 | $data = []; |
| 110 | 108 | foreach ($rawColumns as $name => $value) { |
| 111 | 109 | if ($this->mapper()->hasRelation($name)) { |
| 112 | 110 | $relation = $this->mapper()->getRelated($name); |
| 113 | - if($relation instanceof self){ |
|
| 111 | + if($relation instanceof self) { |
|
| 114 | 112 | $data[$name] = $relation->jsonSerialize(); |
| 115 | 113 | } else { |
| 116 | 114 | $data[$name] = $relation; |
@@ -130,8 +128,7 @@ discard block |
||
| 130 | 128 | * @param string $name |
| 131 | 129 | * @return mixed |
| 132 | 130 | */ |
| 133 | - public function __get(string $name) |
|
| 134 | - { |
|
| 131 | + public function __get(string $name) { |
|
| 135 | 132 | if ($this->mapper()->hasRelation($name)) { |
| 136 | 133 | return $this->mapper()->getRelated($name); |
| 137 | 134 | } |
@@ -152,8 +149,7 @@ discard block |
||
| 152 | 149 | * @param mixed $value |
| 153 | 150 | * @return void |
| 154 | 151 | */ |
| 155 | - public function __set(string $name, $value) |
|
| 156 | - { |
|
| 152 | + public function __set(string $name, $value) { |
|
| 157 | 153 | if ($this->mapper()->hasRelation($name)) { |
| 158 | 154 | if (is_array($value)) { |
| 159 | 155 | foreach ($value as $entity) { |
@@ -172,8 +168,7 @@ discard block |
||
| 172 | 168 | * @param string $name |
| 173 | 169 | * @return bool |
| 174 | 170 | */ |
| 175 | - public function __isset(string $name) |
|
| 176 | - { |
|
| 171 | + public function __isset(string $name) { |
|
| 177 | 172 | return $this->mapper()->hasRelation($name) |
| 178 | 173 | || $this->mapper()->hasColumn($name); |
| 179 | 174 | } |
@@ -183,8 +178,7 @@ discard block |
||
| 183 | 178 | * @param string $name |
| 184 | 179 | * @return bool |
| 185 | 180 | */ |
| 186 | - public function __unset(string $name) |
|
| 187 | - { |
|
| 181 | + public function __unset(string $name) { |
|
| 188 | 182 | $this->mapper()->clearColumn($name, true); |
| 189 | 183 | } |
| 190 | 184 | |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | * @package Platine\Orm\Mapper |
| 61 | 61 | * @template TEntity as Entity |
| 62 | 62 | */ |
| 63 | -class Proxy |
|
| 64 | -{ |
|
| 63 | +class Proxy { |
|
| 65 | 64 | /** |
| 66 | 65 | * The Entity data mapper arguments property |
| 67 | 66 | * @var ReflectionProperty |
@@ -78,8 +77,7 @@ discard block |
||
| 78 | 77 | * Create new instance |
| 79 | 78 | * @throws ReflectionException |
| 80 | 79 | */ |
| 81 | - private function __construct() |
|
| 82 | - { |
|
| 80 | + private function __construct() { |
|
| 83 | 81 | $reflection = new ReflectionClass(Entity::class); |
| 84 | 82 | |
| 85 | 83 | $this->dataMapperArgs = $reflection->getProperty('dataMapperArgs'); |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * @package Platine\Orm\Mapper |
| 54 | 54 | * @template TEntity as \Platine\Orm\Entity |
| 55 | 55 | */ |
| 56 | -interface EntityMapperInterface |
|
| 57 | -{ |
|
| 56 | +interface EntityMapperInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * The name of the entity |
| 60 | 59 | * @param string $name |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * @package Platine\Orm\Mapper |
| 54 | 54 | * @template TEntity as Entity |
| 55 | 55 | */ |
| 56 | -interface DataMapperInterface |
|
| 57 | -{ |
|
| 56 | +interface DataMapperInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * Whether the record is new |
| 60 | 59 | * @return bool |