-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCreateConfigCommand.php
More file actions
67 lines (55 loc) · 1.93 KB
/
Copy pathCreateConfigCommand.php
File metadata and controls
67 lines (55 loc) · 1.93 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace Facile\CodingStandards\Installer\Command;
use Composer\Command\BaseCommand;
use Facile\CodingStandards\Installer\Writer\PhpCsConfigWriter;
use Facile\CodingStandards\Installer\Writer\PhpCsConfigWriterInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class CreateConfigCommand extends BaseCommand
{
/**
* @var PhpCsConfigWriterInterface
*/
private $configWriter;
public function __construct(string $name = null)
{
$this->configWriter = new PhpCsConfigWriter();
parent::__construct($name);
}
public function getConfigWriter(): PhpCsConfigWriterInterface
{
return $this->configWriter;
}
public function setConfigWriter(PhpCsConfigWriterInterface $configWriter): void
{
$this->configWriter = $configWriter;
}
protected function configure(): void
{
$this
->setName('facile-cs-create-config')
->setDescription('Write the facile-coding-standard configuration for php-cs-fixer')
->setDefinition([
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Do not include autoload-dev directories'),
new InputOption('no-risky', null, InputOption::VALUE_NONE, 'Do not include risky rules'),
])
->setHelp(
<<<'HELP'
Write config file in <comment>.php-cs-fixer.dist.php</comment>.
HELP,
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$configWriter = $this->getConfigWriter();
$configWriter->writeConfigFile(
'.php-cs-fixer.dist.php',
(bool) $input->getOption('no-dev'),
(bool) $input->getOption('no-risky'),
);
return 0;
}
}