Skip to content

Commit

Permalink
Apply fixes from StyleCI (#5)
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
Naoray authored Apr 19, 2020
1 parent c71f2f5 commit e5827b6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/Tasks/AddIdentifierField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Naoray\BlueprintNovaAddon\Tasks;

use Closure;
use Blueprint\Models\Column;
use Blueprint\Models\Model;
use Closure;
use Illuminate\Support\Arr;
use Blueprint\Models\Column;

class AddIdentifierField
{
Expand All @@ -25,8 +25,8 @@ public function handle($data, Closure $next): array
{
$column = $this->identifierColumn();

$identifierName = $column->name() === 'id' ? '' : "'" . $column->name() . "'";
$data['fields'] .= 'ID::make(' . $identifierName . ')->sortable(),' . PHP_EOL . PHP_EOL;
$identifierName = $column->name() === 'id' ? '' : "'".$column->name()."'";
$data['fields'] .= 'ID::make('.$identifierName.')->sortable(),'.PHP_EOL.PHP_EOL;
$data['imports'][] = 'ID';

return $next($data);
Expand Down
16 changes: 8 additions & 8 deletions src/Tasks/AddRegularFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Naoray\BlueprintNovaAddon\Tasks;

use Closure;
use Blueprint\Models\Model;
use Blueprint\Models\Column;
use Blueprint\Models\Model;
use Closure;
use Illuminate\Support\Collection;
use Naoray\BlueprintNovaAddon\Translators\Rules;

Expand All @@ -31,14 +31,14 @@ public function handle($data, Closure $next): array
$fieldType = $this->fieldType($column->dataType());
$imports[] = $fieldType;

$field = $fieldType . "::make('" . $this->fieldLabel($column->name()) . "')";
$field = $fieldType."::make('".$this->fieldLabel($column->name())."')";
$field .= $this->addRules($column);

if ($column->dataType() === 'json') {
$field .= PHP_EOL . self::INDENT_PLUS . '->json()';
$field .= PHP_EOL.self::INDENT_PLUS.'->json()';
}

$fields .= self::INDENT . $field . ',' . PHP_EOL . PHP_EOL;
$fields .= self::INDENT.$field.','.PHP_EOL.PHP_EOL;
}

$data['fields'] = $fields;
Expand All @@ -52,7 +52,7 @@ private function regularColumns(array $columns): Collection
return collect($columns)
->filter(function (Column $column) {
return $column->dataType() !== 'id'
&& !collect(['id', 'deleted_at', 'created_at', 'updated_at'])->contains($column->name());
&& ! collect(['id', 'deleted_at', 'created_at', 'updated_at'])->contains($column->name());
});
}

Expand All @@ -68,14 +68,14 @@ private function addRules(Column $column): string
}

$rules = array_map(function ($rule) {
return " '" . $rule . "'";
return " '".$rule."'";
}, Rules::fromColumn($this->model->tableName(), $column));

if (empty($rules)) {
return '';
}

return PHP_EOL . self::INDENT_PLUS . '->rules(' . trim(implode(',', $rules)) . ')';
return PHP_EOL.self::INDENT_PLUS.'->rules('.trim(implode(',', $rules)).')';
}

private function fieldType(string $dataType)
Expand Down
10 changes: 5 additions & 5 deletions src/Tasks/AddRelationshipFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Naoray\BlueprintNovaAddon\Tasks;

use Closure;
use Blueprint\Models\Model;
use Closure;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -47,10 +47,10 @@ public function handle(array $data, Closure $next)
$fieldType = $this->fieldType($type);
$imports[] = $fieldType;

$fields .= self::INDENT . $fieldType . "::make('" . $label . "'";
$fields .= self::INDENT.$fieldType."::make('".$label."'";

if ($this->classNameNotGuessable($label, $class)) {
$fields .= ", '" . $methodName . "', " . $class . '::class';
$fields .= ", '".$methodName."', ".$class.'::class';
}

$fields .= ')';
Expand All @@ -59,7 +59,7 @@ public function handle(array $data, Closure $next)
$fields .= '->nullable()';
}

$fields .= ',' . PHP_EOL;
$fields .= ','.PHP_EOL;
}

$fields .= PHP_EOL;
Expand Down Expand Up @@ -98,7 +98,7 @@ private function isNullable($relation): bool
})
->first();

return !is_null($relationColumnName)
return ! is_null($relationColumnName)
&& in_array('nullable', $this->model->columns()[$relationColumnName]->modifiers());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/InteractWithRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private function relationshipIdentifiers(array $columns): Collection
->map(function (Column $column) {
return empty($column->attributes())
? $column->name()
: implode(':', $column->attributes()) . ":{$column->name()}";
: implode(':', $column->attributes()).":{$column->name()}";
});
}
}
8 changes: 4 additions & 4 deletions tests/NovaGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function setUp(): void
public function output_generates_nothing_for_empty_tree()
{
$this->files->expects('get')
->with($this->stubPath() . DIRECTORY_SEPARATOR . 'class.stub')
->with($this->stubPath().DIRECTORY_SEPARATOR.'class.stub')
->andReturn(file_get_contents('stubs/class.stub'));

$this->files->shouldNotHaveReceived('put');
Expand All @@ -50,7 +50,7 @@ public function output_generates_nothing_for_empty_tree()
public function output_generates_nova_resources($definition, $path, $novaResource)
{
$this->files->expects('get')
->with($this->stubPath() . DIRECTORY_SEPARATOR . 'class.stub')
->with($this->stubPath().DIRECTORY_SEPARATOR.'class.stub')
->andReturn(file_get_contents('stubs/class.stub'));

$this->files->expects('exists')
Expand All @@ -71,7 +71,7 @@ public function output_generates_nova_resources($definition, $path, $novaResourc
public function output_generates_relationships()
{
$this->files->expects('get')
->with($this->stubPath() . DIRECTORY_SEPARATOR . 'class.stub')
->with($this->stubPath().DIRECTORY_SEPARATOR.'class.stub')
->andReturn(file_get_contents('stubs/class.stub'));

$this->files->expects('exists')
Expand All @@ -96,7 +96,7 @@ public function output_respects_configuration()
$this->app['config']->set('blueprint.models_namespace', 'Models');

$this->files->expects('get')
->with($this->stubPath() . DIRECTORY_SEPARATOR . 'class.stub')
->with($this->stubPath().DIRECTORY_SEPARATOR.'class.stub')
->andReturn(file_get_contents('stubs/class.stub'));

$this->files->expects('exists')
Expand Down

0 comments on commit e5827b6

Please sign in to comment.