Set the death year to null for the Anonymous artist

This commit is contained in:
Mike Colagrosso 2024-01-25 00:26:27 -07:00 committed by Alex Cabal
parent fc42f1579a
commit e08dfab9da

View file

@ -3,6 +3,7 @@ use Safe\DateTime;
use function Safe\date; use function Safe\date;
/** /**
* @property ?int $DeathYear
* @property string $UrlName * @property string $UrlName
* @property string $Url * @property string $Url
* @property array<string> $AlternateNames * @property array<string> $AlternateNames
@ -11,13 +12,26 @@ use function Safe\date;
class Artist extends PropertiesBase{ class Artist extends PropertiesBase{
public ?int $ArtistId = null; public ?int $ArtistId = null;
public ?string $Name = null; public ?string $Name = null;
public ?int $DeathYear = null;
public ?datetime $Created = null; public ?datetime $Created = null;
public ?datetime $Updated = null; public ?datetime $Updated = null;
protected ?int $_DeathYear = null;
protected ?string $_UrlName = null; protected ?string $_UrlName = null;
protected ?string $_Url = null; protected ?string $_Url = null;
protected $_AlternateNames; protected $_AlternateNames;
// *******
// SETTERS
// *******
protected function SetDeathYear(?int $deathYear): void{
if($this->Name == 'Anonymous'){
$this->_DeathYear = null;
}
else {
$this->_DeathYear = $deathYear;
}
}
// ******* // *******
// GETTERS // GETTERS
// ******* // *******
@ -81,6 +95,10 @@ class Artist extends PropertiesBase{
$error->Add(new Exceptions\StringTooLongException('Artist Name')); $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)){ if($this->DeathYear !== null && ($this->DeathYear <= 0 || $this->DeathYear > $thisYear + 50)){
$error->Add(new Exceptions\InvalidDeathYearException()); $error->Add(new Exceptions\InvalidDeathYearException());
} }