Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class CreateListenerCommand extends FileCreator |
||
10 | { |
||
11 | /** |
||
12 | * Creates a file with Seed data |
||
13 | * ----------------------------- |
||
14 | * Создает файл с данными Seed |
||
15 | */ |
||
16 | public function actionIndex(): void |
||
17 | { |
||
18 | Cli::printer("Enter listener name: ", "magneta"); |
||
19 | $prefix = str_replace(PHP_EOL, "", Cli::reader()); |
||
20 | $className = ucfirst($prefix) . 'Listener'; |
||
21 | |||
22 | Cli::printer("Enter container: ", "magneta"); |
||
23 | $container = ucfirst(str_replace(PHP_EOL, "", Cli::reader())); |
||
24 | |||
25 | if (!empty($container)) { |
||
26 | |||
27 | $this->writeFile( |
||
28 | [str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Containers/$container/Listener/"), "{$className}.php"], |
||
29 | $this->createClass($className, $container) |
||
30 | ); |
||
31 | |||
32 | } else { |
||
33 | $this->actionIndex(); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Creates class data |
||
39 | * ------------------ |
||
40 | * Создает данные класса |
||
41 | * |
||
42 | * @param string $className |
||
43 | * @param string $container |
||
44 | * @return string |
||
45 | */ |
||
46 | private function createClass(string $className, string $container): string |
||
54 | { |
||
55 | |||
60 |