-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGreetCommand.php
38 lines (31 loc) · 956 Bytes
/
GreetCommand.php
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
<?php
namespace App\UseCase\Greet;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
class GreetCommand extends Command
{
private $handler;
public function __construct(GreetHandler $handler)
{
parent::__construct();
$this->handler = $handler;
}
protected function configure(): void
{
$this
->setName('handler:greet')
->setDescription('Greet someone')
->addArgument('name', InputArgument::REQUIRED, 'Who do you want to greet?')
;
}
protected function execute(InputInterface $input, OutputInterface $output): void
{
($this->handler)(
$input->getArgument('name'),
new ConsoleLogger($output)
);
}
}