| Total Complexity | 7 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 75% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | abstract class ClassGeneratorCommand extends AbstractGeneratorCommand |
||
| 20 | { |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Get the console command arguments. |
||
| 24 | * |
||
| 25 | * @return array |
||
| 26 | */ |
||
| 27 | 26 | protected function setArguments() :array |
|
| 28 | { |
||
| 29 | return [ |
||
| 30 | 26 | ['name', InputArgument::OPTIONAL, 'The name of the ' . $this->getGeneratorName() . '.'] |
|
| 31 | ]; |
||
| 32 | } |
||
| 33 | |||
| 34 | protected function handleNameArgument() |
||
| 35 | { |
||
| 36 | return $this->ask('Specify the name of the ' . $this->getGeneratorName() . '.'); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | 23 | protected function getFileName() :string |
|
| 43 | { |
||
| 44 | 23 | return $this->getClassName() . '.php'; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get class namespace. |
||
| 49 | * |
||
| 50 | * |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 23 | public function getClassNamespace(): string |
|
| 56 | } |
||
| 57 | |||
| 58 | 23 | protected function getClassName(){ |
|
| 59 | 23 | $className = $this->getArgument('name'); |
|
| 60 | 23 | if($className===null){ |
|
| 61 | $this->error('class name not specified'); |
||
| 62 | throw new \Exception('Name of ' . $this->getGeneratorName() . ' not set.'); |
||
| 63 | } |
||
| 64 | 23 | return $className; |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Get the console command options. |
||
| 69 | * |
||
| 70 | * @return array |
||
| 71 | */ |
||
| 72 | 26 | protected function setOptions() :array |
|
| 75 | } |
||
| 76 | } |
||
| 77 |