Encapsulated logic to get rid of nested ifs

This commit is contained in:
Alejandro Celaya
2021-04-18 17:07:56 +02:00
parent b277f431c2
commit e9a5284dde
6 changed files with 95 additions and 57 deletions

View File

@@ -7,6 +7,7 @@ namespace Shlinkio\Shlink\Core\Exception;
use Fig\Http\Message\StatusCodeInterface;
use Mezzio\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
use Mezzio\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
use function sprintf;
@@ -34,4 +35,9 @@ class NonUniqueSlugException extends InvalidArgumentException implements Problem
return $e;
}
public static function fromImport(ImportedShlinkUrl $importedUrl): self
{
return self::fromSlug($importedUrl->shortCode(), $importedUrl->domain());
}
}