From e08dfab9daf84378fbc02b51cb887032e387b596 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Thu, 25 Jan 2024 00:26:27 -0700 Subject: [PATCH] Set the death year to null for the Anonymous artist --- lib/Artist.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Artist.php b/lib/Artist.php index 5fea165f..d45be8b9 100644 --- a/lib/Artist.php +++ b/lib/Artist.php @@ -3,6 +3,7 @@ use Safe\DateTime; use function Safe\date; /** + * @property ?int $DeathYear * @property string $UrlName * @property string $Url * @property array $AlternateNames @@ -11,13 +12,26 @@ use function Safe\date; class Artist extends PropertiesBase{ public ?int $ArtistId = null; public ?string $Name = null; - public ?int $DeathYear = null; public ?datetime $Created = null; public ?datetime $Updated = null; + protected ?int $_DeathYear = null; protected ?string $_UrlName = null; protected ?string $_Url = null; protected $_AlternateNames; + // ******* + // SETTERS + // ******* + + protected function SetDeathYear(?int $deathYear): void{ + if($this->Name == 'Anonymous'){ + $this->_DeathYear = null; + } + else { + $this->_DeathYear = $deathYear; + } + } + // ******* // GETTERS // ******* @@ -81,6 +95,10 @@ class Artist extends PropertiesBase{ $error->Add(new Exceptions\StringTooLongException('Artist Name')); } + if($this->Name == 'Anonymous' && $this->DeathYear !== null){ + $this->_DeathYear = null; + } + if($this->DeathYear !== null && ($this->DeathYear <= 0 || $this->DeathYear > $thisYear + 50)){ $error->Add(new Exceptions\InvalidDeathYearException()); }