Migrated NotFoundRedirectOptions to immutable object

This commit is contained in:
Alejandro Celaya
2022-09-17 13:32:40 +02:00
parent 39693ca1fe
commit 20f457a3e9
5 changed files with 25 additions and 42 deletions

View File

@@ -4,14 +4,16 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Options;
use Laminas\Stdlib\AbstractOptions;
use Shlinkio\Shlink\Core\Config\NotFoundRedirectConfigInterface;
class NotFoundRedirectOptions extends AbstractOptions implements NotFoundRedirectConfigInterface
final class NotFoundRedirectOptions implements NotFoundRedirectConfigInterface
{
private ?string $invalidShortUrl = null;
private ?string $regular404 = null;
private ?string $baseUrl = null;
public function __construct(
public readonly ?string $invalidShortUrl = null,
public readonly ?string $regular404 = null,
public readonly ?string $baseUrl = null,
) {
}
public function invalidShortUrlRedirect(): ?string
{
@@ -23,12 +25,6 @@ class NotFoundRedirectOptions extends AbstractOptions implements NotFoundRedirec
return $this->invalidShortUrl !== null;
}
protected function setInvalidShortUrl(?string $invalidShortUrl): self
{
$this->invalidShortUrl = $invalidShortUrl;
return $this;
}
public function regular404Redirect(): ?string
{
return $this->regular404;
@@ -39,12 +35,6 @@ class NotFoundRedirectOptions extends AbstractOptions implements NotFoundRedirec
return $this->regular404 !== null;
}
protected function setRegular404(?string $regular404): self
{
$this->regular404 = $regular404;
return $this;
}
public function baseUrlRedirect(): ?string
{
return $this->baseUrl;
@@ -54,10 +44,4 @@ class NotFoundRedirectOptions extends AbstractOptions implements NotFoundRedirec
{
return $this->baseUrl !== null;
}
protected function setBaseUrl(?string $baseUrl): self
{
$this->baseUrl = $baseUrl;
return $this;
}
}