-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathServiceCommand.php
More file actions
40 lines (31 loc) · 841 Bytes
/
ServiceCommand.php
File metadata and controls
40 lines (31 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Bow\Console\Command;
use Bow\Console\AbstractCommand;
use Bow\Console\Generator;
use JetBrains\PhpStorm\NoReturn;
class ServiceCommand extends AbstractCommand
{
/**
* Add service
*
* @param string $service
* @return void
*/
public function run(string $service): void
{
$generator = new Generator(
$this->setting->getServiceDirectory(),
$service
);
if ($generator->fileExists()) {
echo "\033[0;31mThe service already exists.\033[00m\n";
exit(1);
}
$generator->write('service', [
'baseNamespace' => $this->namespaces['service'] ?? 'App\\Services'
]);
echo "\033[0;32mThe service has been well created.\033[00m\n";
exit(0);
}
}