godbout /
dash-docset-builder
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Godbout\DashDocsetBuilder\Commands; |
||
| 4 | |||
| 5 | use Godbout\DashDocsetBuilder\Services\DocsetBuilder; |
||
| 6 | use Illuminate\Support\Str; |
||
| 7 | use LaravelZero\Framework\Commands\Command; |
||
| 8 | |||
| 9 | abstract class BaseCommand extends Command |
||
| 10 | { |
||
| 11 | 80 | public function handle() |
|
| 12 | { |
||
| 13 | 80 | $docset = $this->requestedDocset(); |
|
| 14 | 80 | $action = $this->requestedAction(); |
|
| 15 | |||
| 16 | 80 | if ($action === 'new') { |
|
| 17 | 32 | $this->info('New docset class started'); |
|
| 18 | 32 | (new DocsetBuilder(null, $this))->new(); |
|
| 19 | 32 | $this->info('New docset class finished'); |
|
| 20 | |||
| 21 | 32 | return; |
|
| 22 | } |
||
| 23 | |||
| 24 | 48 | if ($this->isSupported()) { |
|
| 25 | 24 | $this->info(Str::ucfirst("$action started")); |
|
| 26 | 24 | (new DocsetBuilder(new $docset(), $this))->$action(); |
|
| 27 | 24 | $this->info(Str::ucfirst("$action finished")); |
|
| 28 | |||
| 29 | 24 | return; |
|
| 30 | } |
||
| 31 | |||
| 32 | 32 | $this->warn('The doc requested does not seem to be supported.'); |
|
| 33 | |||
| 34 | 32 | return 1; |
|
| 35 | } |
||
| 36 | |||
| 37 | 80 | protected function requestedDocset() |
|
| 38 | { |
||
| 39 | 80 | $classBasename = Str::studly($this->argument('doc')); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 40 | |||
| 41 | 80 | return class_exists("App\\Docsets\\$classBasename") |
|
| 42 | ? "App\\Docsets\\$classBasename" |
||
| 43 | 80 | : "Godbout\\DashDocsetBuilder\\Docsets\\$classBasename"; |
|
| 44 | } |
||
| 45 | |||
| 46 | 80 | protected function requestedAction() |
|
| 47 | { |
||
| 48 | 80 | return $this->getName(); |
|
| 49 | } |
||
| 50 | |||
| 51 | 48 | protected function isSupported() |
|
| 52 | { |
||
| 53 | 48 | return class_exists($this->requestedDocset()); |
|
| 54 | } |
||
| 55 | } |
||
| 56 |