Skip to content

Commit edab7a9

Browse files
committed
usecase make command
1 parent 7ebbdcd commit edab7a9

File tree

3 files changed

+132
-1
lines changed

3 files changed

+132
-1
lines changed

src/Commands/TestMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @package Commands
88
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
99
* @license https://mit-license.org/ MIT License
10-
* @version GIT: 0.0.1
10+
* @version GIT: 0.0.6
1111
* @link https://github.com/spotlibs
1212
*/
1313

src/Commands/UsecaseMakeCommand.php

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
/**
4+
* PHP version 8.0.30
5+
*
6+
* @category Application
7+
* @package Commands
8+
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
9+
* @license https://mit-license.org/ MIT License
10+
* @version GIT: 0.0.6
11+
* @link https://github.com/
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace App\Console\Commands;
17+
18+
use Illuminate\Console\GeneratorCommand;
19+
use Symfony\Component\Console\Input\InputOption;
20+
21+
/**
22+
* CollectionMakeCommand
23+
*
24+
* Custom command
25+
*
26+
* @category Console
27+
* @package Commands
28+
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
29+
* @license https://mit-license.org/ MIT License
30+
* @link https://github.com/
31+
*/
32+
class UsecaseMakeCommand extends GeneratorCommand
33+
{
34+
/**
35+
* The console command name.
36+
*
37+
* @var string
38+
*/
39+
protected $name = 'make:usecase';
40+
/**
41+
* The console command description.
42+
*
43+
* @var string
44+
*/
45+
protected $description = 'Create a new usecase for model class';
46+
/**
47+
* The type of class being generated.
48+
*
49+
* @var string
50+
*/
51+
protected $type = 'Usecase';
52+
/**
53+
* Get the destination class path.
54+
*
55+
* @param string $name name of the type
56+
*
57+
* @return string
58+
*/
59+
protected function getPath($name)
60+
{
61+
return parent::getPath($name . 'Usecase');
62+
}
63+
/**
64+
* Get the stub file for the generator.
65+
*
66+
* @return string
67+
*/
68+
protected function getStub()
69+
{
70+
if ($this->option('resource')) {
71+
return __DIR__ . '/stubs/usecase.stub';
72+
}
73+
return __DIR__ . '/stubs/usecase.plain.stub';
74+
}
75+
/**
76+
* Get the default namespace for the class.
77+
*
78+
* @param string $rootNamespace root namespace (generally App)
79+
*
80+
* @return string
81+
*/
82+
protected function getDefaultNamespace($rootNamespace)
83+
{
84+
return $rootNamespace . '\Usecases';
85+
}
86+
/**
87+
* Get the console command options.
88+
*
89+
* @return array
90+
*/
91+
protected function getOptions()
92+
{
93+
return [
94+
['resource', null, InputOption::VALUE_NONE, 'Generate a resource usecase class.'],
95+
];
96+
}
97+
}

src/Commands/stubs/usecase.plain.stub

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* PHP version 8.0.30
5+
*
6+
* @category Application
7+
* @package Usecases
8+
* @author
9+
* @license https://mit-license.org/ MIT License
10+
* @version GIT: 0.0.1
11+
* @link https://github.com/
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace DummyNamespace;
17+
18+
use Illuminate\Http\Request;
19+
20+
/**
21+
* DummyClassUsecase
22+
*
23+
* Execute business logic due to request
24+
*
25+
* @category BusinessLogic
26+
* @package Collections
27+
* @author
28+
* @license https://mit-license.org/ MIT License
29+
* @link https://github.com/
30+
*/
31+
class DummyClassUsecase
32+
{
33+
34+
}

0 commit comments

Comments
 (0)