From 140b89e54a5b19a175fce01d739c1037ece919e2 Mon Sep 17 00:00:00 2001 From: Cristian Llanos Date: Fri, 18 May 2018 02:49:32 +0000 Subject: [PATCH] Apply fixes from StyleCI --- config/models.php | 2 +- src/Coders/Model/Factory.php | 2 +- src/Coders/Model/Model.php | 9 ++++--- src/Coders/Model/Relations/BelongsToMany.php | 26 ++++++++++---------- src/Coders/Model/Relations/HasMany.php | 4 +-- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/config/models.php b/config/models.php index e5bfd0db..5f97d5bf 100644 --- a/config/models.php +++ b/config/models.php @@ -386,7 +386,7 @@ */ 'override_pluralize_for' => [ - ] + ], ], /* diff --git a/src/Coders/Model/Factory.php b/src/Coders/Model/Factory.php index 1f61c241..d3ffdece 100644 --- a/src/Coders/Model/Factory.php +++ b/src/Coders/Model/Factory.php @@ -539,7 +539,7 @@ private function formatBaseClasses(Model $model) */ private function getBaseClassName(Model $model) { - return 'Base' . $model->getClassName(); + return 'Base'.$model->getClassName(); } /** diff --git a/src/Coders/Model/Model.php b/src/Coders/Model/Model.php index 9bbc9122..25c03849 100644 --- a/src/Coders/Model/Model.php +++ b/src/Coders/Model/Model.php @@ -408,13 +408,13 @@ public function shouldQualifyTableName() */ public function shouldPluralizeTableName() { - $pluralize = (bool)$this->config('pluralize', true); + $pluralize = (bool) $this->config('pluralize', true); $overridePluralizeFor = $this->config('override_pluralize_for', []); if (count($overridePluralizeFor) > 0) { foreach ($overridePluralizeFor as $except) { if ($except == $this->getTable()) { - return !$pluralize; + return ! $pluralize; } } } @@ -427,7 +427,7 @@ public function shouldPluralizeTableName() */ public function shouldLowerCaseTableName() { - return (bool)$this->config('lower_table_name_first', false); + return (bool) $this->config('lower_table_name_first', false); } /** @@ -524,6 +524,7 @@ public function getRecordName() if ($this->shouldPluralizeTableName()) { return Str::singular($this->removeTablePrefix($this->blueprint->table())); } + return $this->removeTablePrefix($this->blueprint->table()); } @@ -707,7 +708,7 @@ public function needsTableName() return false === $this->shouldQualifyTableName() || $this->shouldRemoveTablePrefix() || $this->blueprint->table() != Str::plural($this->getRecordName()) || - !$this->shouldPluralizeTableName(); + ! $this->shouldPluralizeTableName(); } /** diff --git a/src/Coders/Model/Relations/BelongsToMany.php b/src/Coders/Model/Relations/BelongsToMany.php index c182a0ea..7b827418 100644 --- a/src/Coders/Model/Relations/BelongsToMany.php +++ b/src/Coders/Model/Relations/BelongsToMany.php @@ -69,7 +69,7 @@ public function __construct( */ public function hint() { - return '\\' . Collection::class . '|' . $this->reference->getQualifiedUserClassName() . '[]'; + return '\\'.Collection::class.'|'.$this->reference->getQualifiedUserClassName().'[]'; } /** @@ -99,32 +99,32 @@ public function body() { $body = 'return $this->belongsToMany('; - $body .= $this->reference->getQualifiedUserClassName() . '::class'; + $body .= $this->reference->getQualifiedUserClassName().'::class'; if ($this->needsPivotTable()) { - $body .= ', ' . Dumper::export($this->pivotTable()); + $body .= ', '.Dumper::export($this->pivotTable()); } if ($this->needsForeignKey()) { $foreignKey = $this->parent->usesPropertyConstants() - ? $this->reference->getQualifiedUserClassName() . '::' . strtoupper($this->foreignKey()) + ? $this->reference->getQualifiedUserClassName().'::'.strtoupper($this->foreignKey()) : $this->foreignKey(); - $body .= ', ' . Dumper::export($foreignKey); + $body .= ', '.Dumper::export($foreignKey); } if ($this->needsOtherKey()) { $otherKey = $this->reference->usesPropertyConstants() - ? $this->reference->getQualifiedUserClassName() . '::' . strtoupper($this->otherKey()) + ? $this->reference->getQualifiedUserClassName().'::'.strtoupper($this->otherKey()) : $this->otherKey(); - $body .= ', ' . Dumper::export($otherKey); + $body .= ', '.Dumper::export($otherKey); } $body .= ')'; $fields = $this->getPivotFields(); - if (!empty($fields)) { - $body .= "\n\t\t\t\t\t->withPivot(" . $this->parametrize($fields) . ')'; + if (! empty($fields)) { + $body .= "\n\t\t\t\t\t->withPivot(".$this->parametrize($fields).')'; } if ($this->pivot->usesTimestamps()) { @@ -165,7 +165,7 @@ protected function pivotTable() */ protected function needsForeignKey() { - $defaultForeignKey = $this->parentRecordName() . '_id'; + $defaultForeignKey = $this->parentRecordName().'_id'; return $this->foreignKey() != $defaultForeignKey || $this->needsOtherKey(); } @@ -183,7 +183,7 @@ protected function foreignKey() */ protected function needsOtherKey() { - $defaultOtherKey = $this->referenceRecordName() . '_id'; + $defaultOtherKey = $this->referenceRecordName().'_id'; return $this->otherKey() != $defaultOtherKey; } @@ -231,9 +231,9 @@ protected function referenceRecordName() */ private function parametrize($fields = []) { - return (string)implode(', ', array_map(function ($field) { + return (string) implode(', ', array_map(function ($field) { $field = $this->reference->usesPropertyConstants() - ? $this->pivot->getQualifiedUserClassName() . '::' . strtoupper($field) + ? $this->pivot->getQualifiedUserClassName().'::'.strtoupper($field) : $field; return Dumper::export($field); diff --git a/src/Coders/Model/Relations/HasMany.php b/src/Coders/Model/Relations/HasMany.php index 7a0fdb54..f1de97a0 100644 --- a/src/Coders/Model/Relations/HasMany.php +++ b/src/Coders/Model/Relations/HasMany.php @@ -7,8 +7,8 @@ namespace Reliese\Coders\Model\Relations; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Str; +use Illuminate\Database\Eloquent\Collection; class HasMany extends HasOneOrMany { @@ -17,7 +17,7 @@ class HasMany extends HasOneOrMany */ public function hint() { - return '\\' . Collection::class . '|' . $this->related->getQualifiedUserClassName() . '[]'; + return '\\'.Collection::class.'|'.$this->related->getQualifiedUserClassName().'[]'; } /**