Skip to content

Commit

Permalink
Merge pull request #94 from reliese/analysis-z4QKVN
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
CristianLlanos authored May 18, 2018
2 parents b747e8d + 140b89e commit 7d037f2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config/models.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
*/
'override_pluralize_for' => [

]
],
],

/*
Expand Down
2 changes: 1 addition & 1 deletion src/Coders/Model/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ private function formatBaseClasses(Model $model)
*/
private function getBaseClassName(Model $model)
{
return 'Base' . $model->getClassName();
return 'Base'.$model->getClassName();
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/Coders/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -524,6 +524,7 @@ public function getRecordName()
if ($this->shouldPluralizeTableName()) {
return Str::singular($this->removeTablePrefix($this->blueprint->table()));
}

return $this->removeTablePrefix($this->blueprint->table());
}

Expand Down Expand Up @@ -707,7 +708,7 @@ public function needsTableName()
return false === $this->shouldQualifyTableName() ||
$this->shouldRemoveTablePrefix() ||
$this->blueprint->table() != Str::plural($this->getRecordName()) ||
!$this->shouldPluralizeTableName();
! $this->shouldPluralizeTableName();
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/Coders/Model/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
*/
public function hint()
{
return '\\' . Collection::class . '|' . $this->reference->getQualifiedUserClassName() . '[]';
return '\\'.Collection::class.'|'.$this->reference->getQualifiedUserClassName().'[]';
}

/**
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -165,7 +165,7 @@ protected function pivotTable()
*/
protected function needsForeignKey()
{
$defaultForeignKey = $this->parentRecordName() . '_id';
$defaultForeignKey = $this->parentRecordName().'_id';

return $this->foreignKey() != $defaultForeignKey || $this->needsOtherKey();
}
Expand All @@ -183,7 +183,7 @@ protected function foreignKey()
*/
protected function needsOtherKey()
{
$defaultOtherKey = $this->referenceRecordName() . '_id';
$defaultOtherKey = $this->referenceRecordName().'_id';

return $this->otherKey() != $defaultOtherKey;
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Coders/Model/Relations/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -17,7 +17,7 @@ class HasMany extends HasOneOrMany
*/
public function hint()
{
return '\\' . Collection::class . '|' . $this->related->getQualifiedUserClassName() . '[]';
return '\\'.Collection::class.'|'.$this->related->getQualifiedUserClassName().'[]';
}

/**
Expand Down

0 comments on commit 7d037f2

Please sign in to comment.