Moved logic to reuse command options to option classes instead of base abstract command classes

This commit is contained in:
Alejandro Celaya
2022-10-06 21:29:27 +02:00
parent 27b680e0cd
commit 1557438fdf
11 changed files with 141 additions and 106 deletions

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Option;
use Cake\Chronos\Chronos;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use function sprintf;
class StartDateOption
{
private readonly DateOption $dateOption;
public function __construct(Command $command, string $descriptionHint)
{
$this->dateOption = new DateOption($command, 'start-date', 's', sprintf(
'Allows to filter %s, returning only those older than provided date.',
$descriptionHint,
));
}
public function get(InputInterface $input, OutputInterface $output): ?Chronos
{
return $this->dateOption->get($input, $output);
}
}