From e5a8272816b29587c7022276d9ad9ed40cd178e0 Mon Sep 17 00:00:00 2001 From: Rosemary Orchard Date: Thu, 25 Aug 2022 14:25:57 +0100 Subject: [PATCH] PSR2?! --- src/Eloquent/Model.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Eloquent/Model.php b/src/Eloquent/Model.php index cf2b3c01b..5836cf83d 100644 --- a/src/Eloquent/Model.php +++ b/src/Eloquent/Model.php @@ -57,15 +57,15 @@ public function getIdAttribute($value = null) { // If we don't have a value for 'id', we will use the Mongo '_id' value. // This allows us to work with models in a more sql-like way. - if (!$value && array_key_exists('_id', $this->attributes)) { + if (! $value && array_key_exists('_id', $this->attributes)) { $value = $this->attributes['_id']; } // Convert ObjectID to string. if ($value instanceof ObjectID) { - return (string)$value; + return (string) $value; } elseif ($value instanceof Binary) { - return (string)$value->getData(); + return (string) $value->getData(); } return $value; @@ -90,7 +90,7 @@ public function fromDateTime($value) } // Let Eloquent convert the value to a DateTime instance. - if (!$value instanceof DateTimeInterface) { + if (! $value instanceof DateTimeInterface) { $value = parent::asDateTime($value); } @@ -145,7 +145,7 @@ public function getTable() */ public function getAttribute($key) { - if (!$key) { + if (! $key) { return; } @@ -157,8 +157,8 @@ public function getAttribute($key) // This checks for embedded relation support. if ( method_exists($this, $key) - && !method_exists(self::class, $key) - && !$this->hasAttributeGetMutator($key) + && ! method_exists(self::class, $key) + && ! $this->hasAttributeGetMutator($key) ) { return $this->getRelationValue($key); } @@ -216,16 +216,16 @@ public function attributesToArray() // nicely when your models are converted to JSON. foreach ($attributes as $key => &$value) { if ($value instanceof ObjectID) { - $value = (string)$value; + $value = (string) $value; } elseif ($value instanceof Binary) { - $value = (string)$value->getData(); + $value = (string) $value->getData(); } } // Convert dot-notation dates. foreach ($this->getDates() as $key) { if (Str::contains($key, '.') && Arr::has($attributes, $key)) { - Arr::set($attributes, $key, (string)$this->asDateTime(Arr::get($attributes, $key))); + Arr::set($attributes, $key, (string) $this->asDateTime(Arr::get($attributes, $key))); } } @@ -245,7 +245,7 @@ public function getCasts() */ public function originalIsEquivalent($key) { - if (!array_key_exists($key, $this->original)) { + if (! array_key_exists($key, $this->original)) { return false; } @@ -273,7 +273,7 @@ public function originalIsEquivalent($key) } return is_numeric($attribute) && is_numeric($original) - && strcmp((string)$attribute, (string)$original) === 0; + && strcmp((string) $attribute, (string) $original) === 0; } /** @@ -354,7 +354,7 @@ protected function pushAttributeValues($column, array $values, $unique = false) foreach ($values as $value) { // Don't add duplicate values when we only want unique values. - if ($unique && (!is_array($current) || in_array($value, $current))) { + if ($unique && (! is_array($current) || in_array($value, $current))) { continue; } @@ -396,7 +396,7 @@ protected function pullAttributeValues($column, array $values) */ public function getForeignKey() { - return Str::snake(class_basename($this)) . '_' . ltrim($this->primaryKey, '_'); + return Str::snake(class_basename($this)).'_'.ltrim($this->primaryKey, '_'); } /** @@ -461,13 +461,13 @@ public function getQueueableRelations() if ($relation instanceof QueueableCollection) { foreach ($relation->getQueueableRelations() as $collectionValue) { - $relations[] = $key . '.' . $collectionValue; + $relations[] = $key.'.'.$collectionValue; } } if ($relation instanceof QueueableEntity) { foreach ($relation->getQueueableRelations() as $entityKey => $entityValue) { - $relations[] = $key . '.' . $entityValue; + $relations[] = $key.'.'.$entityValue; } } }