Skip to content

Commit

Permalink
Merge pull request #12 from spotlibs/feature/exploration
Browse files Browse the repository at this point in the history
usecase make command
  • Loading branch information
m45adiwinata authored Sep 11, 2024
2 parents fba63c0 + edab7a9 commit 3f74c81
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Commands/TestMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package Commands
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
* @license https://mit-license.org/ MIT License
* @version GIT: 0.0.1
* @version GIT: 0.0.6
* @link https://github.com/spotlibs
*/

Expand Down
97 changes: 97 additions & 0 deletions src/Commands/UsecaseMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

/**
* PHP version 8.0.30
*
* @category Application
* @package Commands
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
* @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 <m45adiwinata@gmail.com>
* @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.'],
];
}
}
34 changes: 34 additions & 0 deletions src/Commands/stubs/usecase.plain.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* PHP version 8.0.30
*
* @category Application
* @package Usecases
* @author
* @license https://mit-license.org/ MIT License
* @version GIT: 0.0.1
* @link https://github.com/
*/

declare(strict_types=1);

namespace DummyNamespace;

use Illuminate\Http\Request;

/**
* DummyClassUsecase
*
* Execute business logic due to request
*
* @category BusinessLogic
* @package Collections
* @author
* @license https://mit-license.org/ MIT License
* @link https://github.com/
*/
class DummyClassUsecase
{

}

0 comments on commit 3f74c81

Please sign in to comment.