mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 08:43:13 +08:00
Reduce duplicated code when parsing short codes and domains from CLI
This commit is contained in:
@@ -6,7 +6,6 @@ namespace Shlinkio\Shlink\Core\ShortUrl\Model;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
@@ -32,18 +31,6 @@ final readonly class ShortUrlIdentifier
|
||||
return new self($shortCode, $domain);
|
||||
}
|
||||
|
||||
public static function fromCli(InputInterface $input): self
|
||||
{
|
||||
// Using getArguments and getOptions instead of getArgument(...) and getOption(...) because
|
||||
// the later throw an exception if requested options are not defined
|
||||
/** @var string $shortCode */
|
||||
$shortCode = $input->getArguments()['shortCode'] ?? '';
|
||||
/** @var string|null $domain */
|
||||
$domain = $input->getOptions()['domain'] ?? null;
|
||||
|
||||
return new self($shortCode, $domain);
|
||||
}
|
||||
|
||||
public static function fromShortUrl(ShortUrl $shortUrl): self
|
||||
{
|
||||
$domain = $shortUrl->getDomain();
|
||||
|
||||
Reference in New Issue
Block a user