@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | public function __construct( |
| 42 | 42 | ConnectionLocator $connectionLocator, |
| 43 | 43 | CastingManager $castingManager = null |
| 44 | - ){ |
|
| 44 | + ) { |
|
| 45 | 45 | $this->connectionLocator = $connectionLocator; |
| 46 | 46 | |
| 47 | - if (! $castingManager) { |
|
| 47 | + if (!$castingManager) { |
|
| 48 | 48 | $castingManager = new CastingManager(); |
| 49 | 49 | } |
| 50 | 50 | $this->castingManager = $castingManager; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | unset($this->lazyMappers[$name]); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! isset($this->mappers[$name]) || ! $this->mappers[$name]) { |
|
| 83 | + if (!isset($this->mappers[$name]) || !$this->mappers[$name]) { |
|
| 84 | 84 | throw new InvalidArgumentException(sprintf('Mapper named %s is not registered', $name)); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $mapper = $mapperConfigOrFactory($this); |
| 122 | - if (! $mapper instanceof Mapper) { |
|
| 122 | + if (!$mapper instanceof Mapper) { |
|
| 123 | 123 | throw new InvalidArgumentException( |
| 124 | 124 | 'The mapper generated from the factory is not a valid `Mapper` instance' |
| 125 | 125 | ); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $mapper->entityClass = $mapperConfig->entityClass; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ($mapperConfig->behaviours && ! empty($mapperConfig->behaviours)) { |
|
| 141 | + if ($mapperConfig->behaviours && !empty($mapperConfig->behaviours)) { |
|
| 142 | 142 | $mapper->use(...$mapperConfig->behaviours); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | { |
| 150 | 150 | $this->orm = $orm; |
| 151 | 151 | |
| 152 | - if (! $entityHydrator) { |
|
| 152 | + if (!$entityHydrator) { |
|
| 153 | 153 | $entityHydrator = new GenericEntityHydrator(); |
| 154 | 154 | $entityHydrator->setMapper($this); |
| 155 | 155 | $entityHydrator->setCastingManager($orm->getCastingManager()); |
| 156 | 156 | } |
| 157 | 157 | $this->entityHydrator = $entityHydrator; |
| 158 | 158 | |
| 159 | - if (! $queryBuilder) { |
|
| 159 | + if (!$queryBuilder) { |
|
| 160 | 160 | $queryBuilder = QueryBuilder::getInstance(); |
| 161 | 161 | } |
| 162 | 162 | $this->queryBuilder = $queryBuilder; |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $mapper = $this; |
| 228 | 228 | |
| 229 | 229 | $singular = Inflector::singularize($this->getTableAlias(true)); |
| 230 | - $castingManager->register($singular, function ($value) use ($mapper, $castingManager) { |
|
| 230 | + $castingManager->register($singular, function($value) use ($mapper, $castingManager) { |
|
| 231 | 231 | if ($value instanceof $this->entityClass) { |
| 232 | 232 | return $value; |
| 233 | 233 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | }); |
| 237 | 237 | |
| 238 | 238 | $plural = $this->getTableAlias(true); |
| 239 | - $castingManager->register($plural, function ($values) use ($mapper, $castingManager) { |
|
| 239 | + $castingManager->register($plural, function($values) use ($mapper, $castingManager) { |
|
| 240 | 240 | if ($values instanceof Collection) { |
| 241 | 241 | return $values; |
| 242 | 242 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function getTableAlias($returnTableIfNull = false) |
| 274 | 274 | { |
| 275 | - return (! $this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
| 275 | + return (!$this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | public function getTableReference() |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | return null; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $receivedTracker = ! ! $tracker; |
|
| 345 | - if (! $tracker) { |
|
| 344 | + $receivedTracker = !!$tracker; |
|
| 345 | + if (!$tracker) { |
|
| 346 | 346 | $receivedTracker = false; |
| 347 | 347 | $tracker = new Tracker($this, [$data]); |
| 348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $this->injectRelations($entity, $tracker, $load); |
| 352 | 352 | $entity->setPersistenceState(StateEnum::SYNCHRONIZED); |
| 353 | 353 | |
| 354 | - if (! $receivedTracker) { |
|
| 354 | + if (!$receivedTracker) { |
|
| 355 | 355 | $tracker->replaceRows([$entity]); |
| 356 | 356 | if ($tracker->isDisposable()) { |
| 357 | 357 | unset($tracker); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $queryCallback = $eagerLoad[$name] ?? null; |
| 407 | 407 | $nextLoad = Arr::getChildren($eagerLoad, $name); |
| 408 | 408 | |
| 409 | - if (! $tracker->hasRelation($name)) { |
|
| 409 | + if (!$tracker->hasRelation($name)) { |
|
| 410 | 410 | $tracker->setRelation($name, $relation, $queryCallback); |
| 411 | 411 | } |
| 412 | 412 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | public function getRelation($name): Relation |
| 456 | 456 | { |
| 457 | - if (! $this->hasRelation($name)) { |
|
| 457 | + if (!$this->hasRelation($name)) { |
|
| 458 | 458 | throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper"); |
| 459 | 459 | } |
| 460 | 460 | |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | $this->relations[$name] = $this->orm->createRelation($this, $name, $this->relations[$name]); |
| 463 | 463 | } |
| 464 | 464 | $relation = $this->relations[$name]; |
| 465 | - if (! $relation instanceof Relation) { |
|
| 465 | + if (!$relation instanceof Relation) { |
|
| 466 | 466 | throw new \InvalidArgumentException("Relation named {$name} is not a proper Relation instance"); |
| 467 | 467 | } |
| 468 | 468 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | public function newSaveAction(EntityInterface $entity, $options): BaseAction |
| 518 | 518 | { |
| 519 | - if (! $entity->getPk()) { |
|
| 519 | + if (!$entity->getPk()) { |
|
| 520 | 520 | $action = new Insert($this, $entity, $options); |
| 521 | 521 | } else { |
| 522 | 522 | $action = new Update($this, $entity, $options); |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | protected function assertCanPersistEntity($entity) |
| 555 | 555 | { |
| 556 | - if (! $entity || ! $entity instanceof $this->entityClass) { |
|
| 556 | + if (!$entity || !$entity instanceof $this->entityClass) { |
|
| 557 | 557 | throw new \InvalidArgumentException(sprintf( |
| 558 | 558 | 'Mapper %s can only persist entity of class %s. %s class provided', |
| 559 | 559 | __CLASS__, |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
| 24 | 24 | if ($this->orm->has($foreignMapper)) { |
| 25 | - if (! $foreignMapper instanceof Mapper) { |
|
| 25 | + if (!$foreignMapper instanceof Mapper) { |
|
| 26 | 26 | $foreignMapper = $this->orm->get($foreignMapper); |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | $type = $options[RelationConfig::TYPE]; |
| 30 | 30 | $relationClass = __NAMESPACE__ . '\\' . Str::className($type); |
| 31 | 31 | |
| 32 | - if (! class_exists($relationClass)) { |
|
| 32 | + if (!class_exists($relationClass)) { |
|
| 33 | 33 | throw new \InvalidArgumentException("{$relationClass} does not exist"); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function hydrate(array $attributes = []) |
| 33 | 33 | { |
| 34 | 34 | $attributes = $this->castingManager |
| 35 | - ->castArray($attributes, $this->mapper->getCasts()); |
|
| 35 | + ->castArray($attributes, $this->mapper->getCasts()); |
|
| 36 | 36 | $attributes = Arr::renameKeys($attributes, $this->mapper->getColumnAttributeMap()); |
| 37 | 37 | $class = $this->mapper->getEntityClass() ?? GenericEntity::class; |
| 38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | array_flip($this->mapper->getColumnAttributeMap()) |
| 47 | 47 | ); |
| 48 | 48 | $data = $this->castingManager |
| 49 | - ->castArrayForDb($data, $this->mapper->getCasts()); |
|
| 49 | + ->castArrayForDb($data, $this->mapper->getCasts()); |
|
| 50 | 50 | |
| 51 | 51 | return Arr::only($data, $this->mapper->getColumns()); |
| 52 | 52 | } |