mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 04:03:12 +08:00
35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\CLI\Input;
|
|
|
|
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
readonly final class ShortUrlIdentifierInput
|
|
{
|
|
public function __construct(Command $command, string $shortCodeDesc, string $domainDesc)
|
|
{
|
|
$command
|
|
->addArgument('shortCode', InputArgument::REQUIRED, $shortCodeDesc)
|
|
->addOption('domain', 'd', InputOption::VALUE_REQUIRED, $domainDesc);
|
|
}
|
|
|
|
public function shortCode(InputInterface $input): ?string
|
|
{
|
|
return $input->getArgument('shortCode');
|
|
}
|
|
|
|
public function toShortUrlIdentifier(InputInterface $input): ShortUrlIdentifier
|
|
{
|
|
$shortCode = $input->getArgument('shortCode');
|
|
$domain = $input->getOption('domain');
|
|
|
|
return ShortUrlIdentifier::fromShortCodeAndDomain($shortCode, $domain);
|
|
}
|
|
}
|