1 | <?php |
||
9 | abstract class GeneratorCommand |
||
10 | { |
||
11 | /** |
||
12 | * The type of class being generated. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $type; |
||
17 | |||
18 | /** @var OutputInterface */ |
||
19 | protected $output; |
||
20 | |||
21 | /** @var InputInterface */ |
||
22 | protected $input; |
||
23 | |||
24 | /** @var Composer */ |
||
25 | protected $composer; |
||
26 | |||
27 | /** @var string|null */ |
||
28 | public $outputPath; |
||
29 | |||
30 | public function __construct() |
||
34 | |||
35 | /** |
||
36 | * Get the stub file for the generator. |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | abstract protected function getStub(); |
||
41 | |||
42 | /** |
||
43 | * Execute the console command. |
||
44 | * |
||
45 | * @param InputInterface $input |
||
46 | * @param OutputInterface $output |
||
47 | * @return bool|null |
||
48 | */ |
||
49 | public function __invoke(InputInterface $input, OutputInterface $output) |
||
76 | |||
77 | /** |
||
78 | * Parse the class name and format according to the root namespace. |
||
79 | * |
||
80 | * @param string $name |
||
81 | * @return string |
||
82 | */ |
||
83 | protected function qualifyClass($name) |
||
99 | |||
100 | /** |
||
101 | * Determine if the class already exists. |
||
102 | * |
||
103 | * @param string $rawName |
||
104 | * @return bool |
||
105 | */ |
||
106 | protected function alreadyExists($rawName) |
||
110 | |||
111 | public function info($text) |
||
115 | |||
116 | public function error($text) |
||
120 | |||
121 | protected function getPath($name) |
||
127 | |||
128 | protected function getOutputPath(): string |
||
132 | |||
133 | protected function getNameInput(): string |
||
137 | |||
138 | protected function rootNamespace() |
||
144 | |||
145 | protected function buildClass($name) |
||
151 | |||
152 | protected function replaceNamespace(&$stub, $name) |
||
162 | |||
163 | protected function getNamespace($name) |
||
167 | |||
168 | protected function replaceClass($stub, $name) |
||
174 | |||
175 | protected function getDefaultNamespace(string $rootNamespace) |
||
179 | |||
180 | protected function makeDirectory(string $path) |
||
184 | |||
185 | public function option($name, $default = null) |
||
193 | } |
||
194 |
If you suppress an error, we recommend checking for the error condition explicitly: