BuildCommand::reactOn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/signals
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/signals/
11
 */
12
13
namespace Maslosoft\Signals\Application\Commands;
14
15
use Maslosoft\Addendum\Interfaces\AnnotatedInterface;
16
use Maslosoft\Cli\Shared\Log\Logger;
17
use Maslosoft\Signals\Signal;
18
use Maslosoft\Signals\Utility;
19
use Maslosoft\Sitcom\Command;
20
use Psr\Log\NullLogger;
21
use Symfony\Component\Console\Command\Command as ConsoleCommand;
22
use Symfony\Component\Console\Input\InputInterface;
23
use Symfony\Component\Console\Output\OutputInterface;
24
25
/**
26
 * SignalsCommand
27
 *
28
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
29
 * @codeCoverageIgnore
30
 */
31
class BuildCommand extends ConsoleCommand implements AnnotatedInterface
32
{
33
34
	protected function configure()
35
	{
36
		$this->setName("build");
37
		$this->setDescription("Build signals list");
38
		$this->setDefinition([
39
		]);
40
41
		$help = <<<EOT
42
The <info>build</info> command will scan files for signals and save them to file.
43
EOT;
44
		$this->setHelp($help);
45
	}
46
47
	protected function execute(InputInterface $input, OutputInterface $output)
48
	{
49
		$signal = new Signal();
50
51
		// Set default logger if not configured
52
		$currentLogger = $signal->getLogger();
53
		if ($currentLogger instanceof NullLogger)
54
		{
55
			$signal->setLogger(new Logger($output));
56
		}
57
58
		(new Utility($signal))->generate();
59
	}
60
61
	/**
62
	 * @SlotFor(Command)
63
	 * @param Command $signal
64
	 */
65
	public function reactOn(Command $signal)
66
	{
67
		$signal->add($this, 'signals');
68
	}
69
70
}
71