mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 14:50:39 -04:00
Set the death year to null for the Anonymous artist
This commit is contained in:
parent
fc42f1579a
commit
e08dfab9da
1 changed files with 19 additions and 1 deletions
|
@ -3,6 +3,7 @@ use Safe\DateTime;
|
|||
use function Safe\date;
|
||||
|
||||
/**
|
||||
* @property ?int $DeathYear
|
||||
* @property string $UrlName
|
||||
* @property string $Url
|
||||
* @property array<string> $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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue