Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Apply fixes from StyleCI #18

Merged
merged 1 commit into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Commands/Database/FactoryMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class FactoryMakeCommand extends MakeFactory
*/
protected function resolveDirectory()
{
return $this->getDirInput() . '/database/factories/';
return $this->getDirInput().'/database/factories/';
}
}
92 changes: 46 additions & 46 deletions src/Commands/Database/MigrationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,57 @@ class MigrationMakeCommand extends MakeMigration
*
* @var string
*/
protected $signature = null;

/**
* Create a new migration install command instance.
*
* @param Illuminate\Filesystem\Filesystem $creator
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
* @param \Illuminate\Support\Composer $composer
* @return void
*/
public function __construct(Filesystem $files, MigrationCreator $creator, Composer $composer)
{
parent::__construct($creator, $composer);

$this->files = $files;
}

/**
* Get migration path (either specified by '--path' option or default location).
*
* @return string
*/
protected function getMigrationPath()
{
$path = $this->basePath() . 'database/migrations';

if (!is_null($targetPath = $this->input->getOption('path'))) {
$path = !$this->usingRealPath()
? $this->basePath() . $targetPath
protected $signature = null;

/**
* Create a new migration install command instance.
*
* @param Illuminate\Filesystem\Filesystem $creator
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
* @param \Illuminate\Support\Composer $composer
* @return void
*/
public function __construct(Filesystem $files, MigrationCreator $creator, Composer $composer)
{
parent::__construct($creator, $composer);

$this->files = $files;
}

/**
* Get migration path (either specified by '--path' option or default location).
*
* @return string
*/
protected function getMigrationPath()
{
$path = $this->basePath().'database/migrations';

if (! is_null($targetPath = $this->input->getOption('path'))) {
$path = ! $this->usingRealPath()
? $this->basePath().$targetPath
: $targetPath;
}

$this->makeDirectory($path . '/some_migration.php');
$this->makeDirectory($path.'/some_migration.php');

return $path;
}
return $path;
}

/**
* Build the directory for the class if necessary.
*
* @param string $path
* @return string
*/
protected function makeDirectory($path)
{
if (!$this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0777, true, true);
}
/**
* Build the directory for the class if necessary.
*
* @param string $path
* @return string
*/
protected function makeDirectory($path)
{
if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0777, true, true);
}

return $path;
}
return $path;
}

/**
* Adds additional options to the command.
Expand All @@ -95,4 +95,4 @@ protected function additionalOptions()
['realpath', null, InputOption::VALUE_REQUIRED, 'Indicate any provided migration file paths are pre - resolved absolute paths'],
];
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/Foundation/EventMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class EventMakeCommand extends MakeEvent
*/
protected function resolveDirectory()
{
return $this->getDirInput() . '/src';
return $this->getDirInput().'/src';
}
}
97 changes: 48 additions & 49 deletions src/Commands/Foundation/ModelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Naoray\LaravelPackageMaker\Commands\Foundation;

use Symfony\Component\Console\Input\InputOption;
use Naoray\LaravelPackageMaker\Traits\HasNameAttribute;
use Naoray\LaravelPackageMaker\Traits\CreatesPackageStubs;
use Illuminate\Foundation\Console\ModelMakeCommand as MakeModel;
Expand All @@ -25,59 +24,59 @@ class ModelMakeCommand extends MakeModel
*/
protected function resolveDirectory()
{
return $this->getDirInput() . 'src';
}
return $this->getDirInput().'src';
}

/**
* Create a model factory for the model.
*
* @return void
*/
protected function createFactory()
{
$factory = studly_case(class_basename($this->argument('name')));
/**
* Create a model factory for the model.
*
* @return void
*/
protected function createFactory()
{
$factory = studly_case(class_basename($this->argument('name')));

$this->call('make:package:factory', [
'name' => "{$factory}Factory",
'--model' => $this->argument('name'),
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
]);
}
$this->call('make:package:factory', [
'name' => "{$factory}Factory",
'--model' => $this->argument('name'),
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
]);
}

/**
* Create a migration file for the model.
*
* @return void
*/
protected function createMigration()
{
$table = str_plural(snake_case(class_basename($this->argument('name'))));
/**
* Create a migration file for the model.
*
* @return void
*/
protected function createMigration()
{
$table = str_plural(snake_case(class_basename($this->argument('name'))));

$this->call('make:package:migration', [
'name' => "create_{$table}_table",
'--create' => $table,
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
]);
}
$this->call('make:package:migration', [
'name' => "create_{$table}_table",
'--create' => $table,
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
]);
}

/**
* Create a controller for the model.
*
* @return void
*/
protected function createController()
{
$controller = studly_case(class_basename($this->argument('name')));
/**
* Create a controller for the model.
*
* @return void
*/
protected function createController()
{
$controller = studly_case(class_basename($this->argument('name')));

$modelName = $this->qualifyClass($this->getNameInput());
$modelName = $this->qualifyClass($this->getNameInput());

$this->call('make:packae:controller', [
'name' => "{$controller}Controller",
'--model' => $this->option('resource') ? $modelName : null,
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
]);
}
$this->call('make:packae:controller', [
'name' => "{$controller}Controller",
'--model' => $this->option('resource') ? $modelName : null,
'--namespace' => $this->rootNamespace(),
'--dir' => $this->basePath(),
]);
}
}
121 changes: 60 additions & 61 deletions src/Commands/Foundation/PolicyMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,70 @@

namespace Naoray\LaravelPackageMaker\Commands\Foundation;

use Symfony\Component\Console\Input\InputOption;
use Naoray\LaravelPackageMaker\Traits\HasNameAttribute;
use Naoray\LaravelPackageMaker\Traits\CreatesPackageStubs;
use Illuminate\Foundation\Console\PolicyMakeCommand as MakePolicy;

class PolicyMakeCommand extends MakePolicy
{
use CreatesPackageStubs, HasNameAttribute;

/**
* The console command name.
*
* @var string
*/
protected $name = 'make:package:policy';

/**
* Get the destination class path.
*
* @return string
*/
protected function resolveDirectory()
{
return $this->getDirInput() . '/src';
}

/**
* Replace the model for the given stub.
*
* @param string $stub
* @param string $model
* @return string
*/
protected function replaceModel($stub, $model)
{
$model = str_replace('/', '\\', $model);

$namespaceModel = $this->rootNamespace() . '\\' . $model;

if (starts_with($model, '\\')) {
$stub = str_replace('NamespacedDummyModel', trim($model, '\\'), $stub);
} else {
$stub = str_replace('NamespacedDummyModel', $namespaceModel, $stub);
}

$stub = str_replace(
"use {$namespaceModel};\nuse {$namespaceModel};",
"use {$namespaceModel};",
$stub
);

$model = class_basename(trim($model, '\\'));

$dummyUser = class_basename(config('auth.providers.users.model'));

$dummyModel = camel_case($model) === 'user' ? 'model' : $model;

$stub = str_replace('DocDummyModel', snake_case($dummyModel, ' '), $stub);

$stub = str_replace('DummyModel', $model, $stub);

$stub = str_replace('dummyModel', camel_case($dummyModel), $stub);

$stub = str_replace('DummyUser', $dummyUser, $stub);

return str_replace('DocDummyPluralModel', snake_case(str_plural($dummyModel), ' '), $stub);
}
use CreatesPackageStubs, HasNameAttribute;

/**
* The console command name.
*
* @var string
*/
protected $name = 'make:package:policy';

/**
* Get the destination class path.
*
* @return string
*/
protected function resolveDirectory()
{
return $this->getDirInput().'/src';
}

/**
* Replace the model for the given stub.
*
* @param string $stub
* @param string $model
* @return string
*/
protected function replaceModel($stub, $model)
{
$model = str_replace('/', '\\', $model);

$namespaceModel = $this->rootNamespace().'\\'.$model;

if (starts_with($model, '\\')) {
$stub = str_replace('NamespacedDummyModel', trim($model, '\\'), $stub);
} else {
$stub = str_replace('NamespacedDummyModel', $namespaceModel, $stub);
}

$stub = str_replace(
"use {$namespaceModel};\nuse {$namespaceModel};",
"use {$namespaceModel};",
$stub
);

$model = class_basename(trim($model, '\\'));

$dummyUser = class_basename(config('auth.providers.users.model'));

$dummyModel = camel_case($model) === 'user' ? 'model' : $model;

$stub = str_replace('DocDummyModel', snake_case($dummyModel, ' '), $stub);

$stub = str_replace('DummyModel', $model, $stub);

$stub = str_replace('dummyModel', camel_case($dummyModel), $stub);

$stub = str_replace('DummyUser', $dummyUser, $stub);

return str_replace('DocDummyPluralModel', snake_case(str_plural($dummyModel), ' '), $stub);
}
}
Loading