| Total Complexity | 7 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 95.83% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | abstract class BaseCommand extends Command |
||
| 11 | { |
||
| 12 | 54 | public function handle() |
|
| 13 | { |
||
| 14 | 54 | $docset = $this->requestedDocset(); |
|
| 15 | 54 | $action = $this->requestedAction(); |
|
| 16 | |||
| 17 | 54 | if ($action === 'new') { |
|
| 18 | 18 | $this->info('New Docset started'); |
|
| 19 | 18 | (new DocsetBuilder(null, $this))->new(); |
|
| 20 | 18 | $this->info('New Docset finished'); |
|
| 21 | |||
| 22 | 18 | return; |
|
| 23 | } |
||
| 24 | |||
| 25 | 36 | if ($this->isSupported()) { |
|
| 26 | 18 | $this->info(Str::ucfirst("$action started")); |
|
| 27 | 18 | (new DocsetBuilder(new $docset(), $this))->$action(); |
|
| 28 | 18 | $this->info(Str::ucfirst("$action finished")); |
|
| 29 | |||
| 30 | 18 | return; |
|
| 31 | } |
||
| 32 | |||
| 33 | 24 | $this->warn('The doc requested does not seem to be supported.'); |
|
| 34 | |||
| 35 | 24 | return 1; |
|
| 36 | } |
||
| 37 | |||
| 38 | 54 | protected function requestedDocset() |
|
| 39 | { |
||
| 40 | 54 | $classBasename = Str::studly($this->argument('doc')); |
|
|
|
|||
| 41 | |||
| 42 | 54 | return class_exists("App\\Docsets\\$classBasename") |
|
| 43 | ? "App\\Docsets\\$classBasename" |
||
| 44 | 54 | : "Godbout\\DashDocsetBuilder\\Docsets\\$classBasename"; |
|
| 45 | } |
||
| 46 | |||
| 47 | 54 | protected function requestedAction() |
|
| 50 | } |
||
| 51 | |||
| 52 | 36 | protected function isSupported() |
|
| 55 | } |
||
| 56 | } |
||
| 57 |