-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathGenerateExceptionCommand.php
More file actions
39 lines (30 loc) · 849 Bytes
/
GenerateExceptionCommand.php
File metadata and controls
39 lines (30 loc) · 849 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
<?php
declare(strict_types=1);
namespace Bow\Console\Command\Generator;
use Bow\Console\AbstractCommand;
use Bow\Console\Generator;
class GenerateExceptionCommand extends AbstractCommand
{
/**
* Add middleware
*
* @param string $exception
* @return void
*/
public function run(string $exception): void
{
$generator = new Generator(
$this->setting->getExceptionDirectory(),
$exception
);
if ($generator->fileExists()) {
echo "\033[0;31mThe exception already exists.\033[00m\n";
exit(1);
}
$generator->write('exception', [
'baseNamespace' => $this->namespaces['exception'] ?? 'App\\Exceptions'
]);
echo "\033[0;32mThe exception has been well created.\033[00m\n";
exit(0);
}
}