diff --git a/src/Commands/TestMakeCommand.php b/src/Commands/TestMakeCommand.php index 25e14cb..2c4f9e9 100644 --- a/src/Commands/TestMakeCommand.php +++ b/src/Commands/TestMakeCommand.php @@ -7,7 +7,7 @@ * @package Commands * @author Made Mas Adi Winata * @license https://mit-license.org/ MIT License - * @version GIT: 0.0.1 + * @version GIT: 0.0.6 * @link https://github.com/spotlibs */ diff --git a/src/Commands/UsecaseMakeCommand.php b/src/Commands/UsecaseMakeCommand.php new file mode 100644 index 0000000..3736c32 --- /dev/null +++ b/src/Commands/UsecaseMakeCommand.php @@ -0,0 +1,97 @@ + + * @license https://mit-license.org/ MIT License + * @version GIT: 0.0.6 + * @link https://github.com/ + */ + +declare(strict_types=1); + +namespace App\Console\Commands; + +use Illuminate\Console\GeneratorCommand; +use Symfony\Component\Console\Input\InputOption; + +/** + * CollectionMakeCommand + * + * Custom command + * + * @category Console + * @package Commands + * @author Made Mas Adi Winata + * @license https://mit-license.org/ MIT License + * @link https://github.com/ + */ +class UsecaseMakeCommand extends GeneratorCommand +{ + /** + * The console command name. + * + * @var string + */ + protected $name = 'make:usecase'; + /** + * The console command description. + * + * @var string + */ + protected $description = 'Create a new usecase for model class'; + /** + * The type of class being generated. + * + * @var string + */ + protected $type = 'Usecase'; + /** + * Get the destination class path. + * + * @param string $name name of the type + * + * @return string + */ + protected function getPath($name) + { + return parent::getPath($name . 'Usecase'); + } + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + if ($this->option('resource')) { + return __DIR__ . '/stubs/usecase.stub'; + } + return __DIR__ . '/stubs/usecase.plain.stub'; + } + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace root namespace (generally App) + * + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace . '\Usecases'; + } + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['resource', null, InputOption::VALUE_NONE, 'Generate a resource usecase class.'], + ]; + } +} diff --git a/src/Commands/stubs/usecase.plain.stub b/src/Commands/stubs/usecase.plain.stub new file mode 100644 index 0000000..e32b7c6 --- /dev/null +++ b/src/Commands/stubs/usecase.plain.stub @@ -0,0 +1,34 @@ +