Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractCommand
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 configure
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 canExecute
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 writeLn
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOptionValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace WsdlToPhp\PackageGenerator\Command;
6
7use Symfony\Component\Console\Command\Command;
8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface;
11
12abstract class AbstractCommand extends Command
13{
14    public const EXIT_OK = 0;
15
16    protected InputInterface $input;
17
18    protected OutputInterface $output;
19
20    protected function configure(): void
21    {
22        $this->addOption(
23            'force',
24            null,
25            InputOption::VALUE_NONE,
26            'If true, then package is really generated otherwise debug information are displayed'
27        );
28    }
29
30    protected function execute(InputInterface $input, OutputInterface $output): int
31    {
32        $this->input = $input;
33        $this->output = $output;
34
35        return self::EXIT_OK;
36    }
37
38    protected function canExecute(): bool
39    {
40        return true === (bool) $this->getOptionValue('force');
41    }
42
43    protected function writeLn($messages, int $type = OutputInterface::OUTPUT_NORMAL): void
44    {
45        $this->output->writeln($messages, $type);
46    }
47
48    protected function getOptionValue(string $name)
49    {
50        return $this->input->getOption($name);
51    }
52}