@@ -63,8 +63,7 @@ discard block |
||
63 | 63 | * @class Repository |
64 | 64 | * @package Platine\Orm |
65 | 65 | */ |
66 | -class Repository implements RepositoryInterface |
|
67 | -{ |
|
66 | +class Repository implements RepositoryInterface { |
|
68 | 67 | /** |
69 | 68 | * The entity class |
70 | 69 | * @var class-string |
@@ -124,8 +123,7 @@ discard block |
||
124 | 123 | * @param EntityManager $manager |
125 | 124 | * @param class-string $entityClass |
126 | 125 | */ |
127 | - public function __construct(EntityManager $manager, string $entityClass) |
|
128 | - { |
|
126 | + public function __construct(EntityManager $manager, string $entityClass) { |
|
129 | 127 | $this->manager = $manager; |
130 | 128 | $this->entityClass = $entityClass; |
131 | 129 | } |
@@ -297,8 +295,7 @@ discard block |
||
297 | 295 | /** |
298 | 296 | * {@inheritedoc} |
299 | 297 | */ |
300 | - public function insert(Entity $entity) |
|
301 | - { |
|
298 | + public function insert(Entity $entity) { |
|
302 | 299 | $data = Proxy::instance()->getEntityDataMapper($entity); |
303 | 300 | $mapper = $data->getEntityMapper(); |
304 | 301 | $eventsHandlers = $mapper->getEventHandlers(); |
@@ -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 | } |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | * @class EntityQuery |
65 | 65 | * @package Platine\Orm\Query |
66 | 66 | */ |
67 | -class EntityQuery extends Query |
|
68 | -{ |
|
67 | +class EntityQuery extends Query { |
|
69 | 68 | /** |
70 | 69 | * |
71 | 70 | * @var EntityManager |
@@ -330,8 +329,7 @@ discard block |
||
330 | 329 | * @param string|Expression|Closure $column |
331 | 330 | * @return mixed |
332 | 331 | */ |
333 | - public function column($column) |
|
334 | - { |
|
332 | + public function column($column) { |
|
335 | 333 | (new ColumnExpression($this->queryStatement))->column($column); |
336 | 334 | |
337 | 335 | return $this->executeAggregate(); |
@@ -343,8 +341,7 @@ discard block |
||
343 | 341 | * @param bool $distinct |
344 | 342 | * @return mixed |
345 | 343 | */ |
346 | - public function count($column = '*', bool $distinct = true) |
|
347 | - { |
|
344 | + public function count($column = '*', bool $distinct = true) { |
|
348 | 345 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
349 | 346 | |
350 | 347 | return $this->executeAggregate(); |
@@ -356,8 +353,7 @@ discard block |
||
356 | 353 | * @param bool $distinct |
357 | 354 | * @return mixed |
358 | 355 | */ |
359 | - public function avg($column, bool $distinct = true) |
|
360 | - { |
|
356 | + public function avg($column, bool $distinct = true) { |
|
361 | 357 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
362 | 358 | |
363 | 359 | return $this->executeAggregate(); |
@@ -369,8 +365,7 @@ discard block |
||
369 | 365 | * @param bool $distinct |
370 | 366 | * @return mixed |
371 | 367 | */ |
372 | - public function sum($column, bool $distinct = true) |
|
373 | - { |
|
368 | + public function sum($column, bool $distinct = true) { |
|
374 | 369 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
375 | 370 | |
376 | 371 | return $this->executeAggregate(); |
@@ -382,8 +377,7 @@ discard block |
||
382 | 377 | * @param bool $distinct |
383 | 378 | * @return mixed |
384 | 379 | */ |
385 | - public function min($column, bool $distinct = true) |
|
386 | - { |
|
380 | + public function min($column, bool $distinct = true) { |
|
387 | 381 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
388 | 382 | |
389 | 383 | return $this->executeAggregate(); |
@@ -395,8 +389,7 @@ discard block |
||
395 | 389 | * @param bool $distinct |
396 | 390 | * @return mixed |
397 | 391 | */ |
398 | - public function max($column, bool $distinct = true) |
|
399 | - { |
|
392 | + public function max($column, bool $distinct = true) { |
|
400 | 393 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
401 | 394 | |
402 | 395 | return $this->executeAggregate(); |
@@ -405,8 +398,7 @@ discard block |
||
405 | 398 | /** |
406 | 399 | * Clone of object |
407 | 400 | */ |
408 | - public function __clone() |
|
409 | - { |
|
401 | + public function __clone() { |
|
410 | 402 | parent::__clone(); |
411 | 403 | $this->havingStatement = new HavingStatement($this->queryStatement); |
412 | 404 | } |
@@ -495,8 +487,7 @@ discard block |
||
495 | 487 | * Execute the aggregate |
496 | 488 | * @return mixed |
497 | 489 | */ |
498 | - protected function executeAggregate() |
|
499 | - { |
|
490 | + protected function executeAggregate() { |
|
500 | 491 | $this->queryStatement->addTables([$this->mapper->getTable()]); |
501 | 492 | |
502 | 493 | if ($this->mapper->hasSoftDelete()) { |
@@ -531,8 +522,7 @@ discard block |
||
531 | 522 | * |
532 | 523 | * @return mixed |
533 | 524 | */ |
534 | - protected function transaction(Closure $callback) |
|
535 | - { |
|
525 | + protected function transaction(Closure $callback) { |
|
536 | 526 | return $this->manager->getConnection() |
537 | 527 | ->transaction($callback); |
538 | 528 | } |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * Class Query |
58 | 58 | * @package Platine\Orm\Query |
59 | 59 | */ |
60 | -class Query extends BaseStatement |
|
61 | -{ |
|
60 | +class Query extends BaseStatement { |
|
62 | 61 | /** |
63 | 62 | * |
64 | 63 | * @var HavingStatement |
@@ -94,8 +93,7 @@ discard block |
||
94 | 93 | * |
95 | 94 | * @param QueryStatement|null $queryStatement |
96 | 95 | */ |
97 | - public function __construct(QueryStatement $queryStatement = null) |
|
98 | - { |
|
96 | + public function __construct(QueryStatement $queryStatement = null) { |
|
99 | 97 | parent::__construct($queryStatement); |
100 | 98 | $this->havingStatement = new HavingStatement($this->queryStatement); |
101 | 99 | } |
@@ -103,8 +101,7 @@ discard block |
||
103 | 101 | /** |
104 | 102 | * Clone the object |
105 | 103 | */ |
106 | - public function __clone() |
|
107 | - { |
|
104 | + public function __clone() { |
|
108 | 105 | parent::__clone(); |
109 | 106 | $this->havingStatement = new HavingStatement($this->queryStatement); |
110 | 107 | } |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * Class Proxy |
60 | 60 | * @package Platine\Orm\Mapper |
61 | 61 | */ |
62 | -class Proxy |
|
63 | -{ |
|
62 | +class Proxy { |
|
64 | 63 | /** |
65 | 64 | * The Entity data mapper arguments property |
66 | 65 | * @var ReflectionProperty |
@@ -77,8 +76,7 @@ discard block |
||
77 | 76 | * Create new instance |
78 | 77 | * @throws ReflectionException |
79 | 78 | */ |
80 | - private function __construct() |
|
81 | - { |
|
79 | + private function __construct() { |
|
82 | 80 | $reflection = new ReflectionClass(Entity::class); |
83 | 81 | |
84 | 82 | $this->dataMapperArgs = $reflection->getProperty('dataMapperArgs'); |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class DataMapperInterface |
53 | 53 | * @package Platine\Orm\Mapper |
54 | 54 | */ |
55 | -interface DataMapperInterface |
|
56 | -{ |
|
55 | +interface DataMapperInterface { |
|
57 | 56 | /** |
58 | 57 | * Whether the record is new |
59 | 58 | * @return bool |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class ShareOne |
51 | 51 | * @package Platine\Orm\Relation |
52 | 52 | */ |
53 | -class ShareOne extends ShareRelation |
|
54 | -{ |
|
53 | +class ShareOne extends ShareRelation { |
|
55 | 54 | /** |
56 | 55 | * {@inheritedoc} |
57 | 56 | */ |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class HasOne |
51 | 51 | * @package Platine\Orm\Relation |
52 | 52 | */ |
53 | -class HasOne extends HasRelation |
|
54 | -{ |
|
53 | +class HasOne extends HasRelation { |
|
55 | 54 | /** |
56 | 55 | * {@inheritedoc} |
57 | 56 | */ |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * Class RelationLoader |
56 | 56 | * @package Platine\Orm\Relation |
57 | 57 | */ |
58 | -class RelationLoader |
|
59 | -{ |
|
58 | +class RelationLoader { |
|
60 | 59 | /** |
61 | 60 | * |
62 | 61 | * @var EntityQuery |
@@ -123,8 +122,7 @@ discard block |
||
123 | 122 | * @param DataMapper $mapper |
124 | 123 | * @return null|Entity|array<int, Entity> |
125 | 124 | */ |
126 | - public function getResult(DataMapper $mapper) |
|
127 | - { |
|
125 | + public function getResult(DataMapper $mapper) { |
|
128 | 126 | $results = $this->loadResults(); |
129 | 127 | |
130 | 128 | if ($this->inverse) { |