Skip to content

Commit

Permalink
Apply fixes from StyleCI (#21)
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
Naoray authored Aug 3, 2020
1 parent d3f3cd7 commit 5a90c2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions src/NovaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Naoray\BlueprintNovaAddon;

use Blueprint\Tree;
use Blueprint\Blueprint;
use Blueprint\Contracts\Generator;
use Blueprint\Models\Model;
use Illuminate\Support\Str;
use Blueprint\Tree;
use Illuminate\Pipeline\Pipeline;
use Blueprint\Contracts\Generator;
use Illuminate\Support\Str;
use Naoray\BlueprintNovaAddon\Contracts\Task;
use Naoray\BlueprintNovaAddon\Tasks\RemapImports;
use Naoray\BlueprintNovaAddon\Tasks\AddTimestampFields;
use Naoray\BlueprintNovaAddon\Tasks\RemapImports;

class NovaGenerator implements Generator
{
Expand All @@ -34,13 +34,13 @@ public function output(Tree $tree): array
{
$output = [];

$stub = $this->files->get($this->stubPath() . DIRECTORY_SEPARATOR . 'class.stub');
$stub = $this->files->get($this->stubPath().DIRECTORY_SEPARATOR.'class.stub');

/** @var \Blueprint\Models\Model $model */
foreach ($tree->models() as $model) {
$path = $this->getPath($model);

if (!$this->files->exists(dirname($path))) {
if (! $this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0755, true);
}

Expand All @@ -54,9 +54,9 @@ public function output(Tree $tree): array

protected function getPath(Model $model): string
{
$path = str_replace('\\', '/', Blueprint::relativeNamespace($this->getNovaNamespace($model) . '/' . $model->name()));
$path = str_replace('\\', '/', Blueprint::relativeNamespace($this->getNovaNamespace($model).'/'.$model->name()));

return config('blueprint.app_path') . '/' . $path . '.php';
return config('blueprint.app_path').'/'.$path.'.php';
}

protected function populateStub(string $stub, Model $model): string
Expand All @@ -72,7 +72,7 @@ protected function populateStub(string $stub, Model $model): string

$stub = str_replace('DummyNamespace', $this->getNovaNamespace($model), $stub);
$stub = str_replace('DummyClass', $model->name(), $stub);
$stub = str_replace('DummyModel', '\\' . $model->fullyQualifiedClassName(), $stub);
$stub = str_replace('DummyModel', '\\'.$model->fullyQualifiedClassName(), $stub);
$stub = str_replace('// fields...', $data['fields'], $stub);
$stub = str_replace('use Illuminate\Http\Request;', implode(PHP_EOL, $data['imports']), $stub);

Expand All @@ -82,10 +82,10 @@ protected function populateStub(string $stub, Model $model): string
protected function getNovaNamespace(Model $model): string
{
$namespace = Str::after($model->fullyQualifiedNamespace(), config('blueprint.namespace'));
$namespace = config('blueprint.namespace') . '\Nova' . $namespace;
$namespace = config('blueprint.namespace').'\Nova'.$namespace;

if (config('blueprint.models_namespace')) {
$namespace = str_replace('\\' . config('blueprint.models_namespace'), '', $namespace);
$namespace = str_replace('\\'.config('blueprint.models_namespace'), '', $namespace);
}

return $namespace;
Expand All @@ -110,7 +110,7 @@ protected function filteredTasks(): array
{
$tasks = $this->tasks;

if (!config('nova_blueprint.timestamps')) {
if (! config('nova_blueprint.timestamps')) {
$tasks = array_filter($tasks, function ($key) {
return $key !== AddTimestampFields::class;
}, ARRAY_FILTER_USE_KEY);
Expand Down
16 changes: 8 additions & 8 deletions tests/NovaGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Naoray\BlueprintNovaAddon\Tests;

use Blueprint\Tree;
use Blueprint\Blueprint;
use Blueprint\Tree;
use Naoray\BlueprintNovaAddon\HasStubPath;
use Naoray\BlueprintNovaAddon\NovaGenerator;
use Naoray\BlueprintNovaAddon\Tasks\AddRegularFields;
use Naoray\BlueprintNovaAddon\Tasks\AddIdentifierField;
use Naoray\BlueprintNovaAddon\Tasks\AddTimestampFields;
use Naoray\BlueprintNovaAddon\Tasks\AddRegularFields;
use Naoray\BlueprintNovaAddon\Tasks\AddRelationshipFields;
use Naoray\BlueprintNovaAddon\Tasks\AddTimestampFields;

class NovaGeneratorTest extends TestCase
{
Expand Down Expand Up @@ -44,7 +44,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 @@ -59,7 +59,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 @@ -81,7 +81,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 @@ -106,7 +106,7 @@ public function output_respects_blueprint_configurations()
$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 All @@ -131,7 +131,7 @@ public function output_respects_packages_configuration()
$this->app['config']->set('nova_blueprint.timestamps', false);

$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 5a90c2d

Please sign in to comment.