mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 03:16:36 -04:00
Style tweaks for getters and add more type hinting
This commit is contained in:
parent
9e31ed1aac
commit
50efeb05d1
13 changed files with 87 additions and 84 deletions
|
@ -80,6 +80,9 @@ class Artist extends Accessor{
|
|||
// METHODS
|
||||
// *******
|
||||
|
||||
/**
|
||||
* @throws Exceptions\InvalidArtistException
|
||||
*/
|
||||
public function Validate(): void{
|
||||
$now = new DateTimeImmutable();
|
||||
$thisYear = intval($now->format('Y'));
|
||||
|
@ -110,6 +113,10 @@ class Artist extends Accessor{
|
|||
// ORM METHODS
|
||||
// ***********
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exceptions\ArtistNotFoundException
|
||||
*/
|
||||
public static function Get(?int $artistId): Artist{
|
||||
if($artistId === null){
|
||||
throw new Exceptions\ArtistNotFoundException();
|
||||
|
@ -121,11 +128,7 @@ class Artist extends Accessor{
|
|||
where ArtistId = ?
|
||||
', [$artistId], 'Artist');
|
||||
|
||||
if(sizeof($result) == 0){
|
||||
throw new Exceptions\ArtistNotFoundException();
|
||||
}
|
||||
|
||||
return $result[0];
|
||||
return $result[0] ?? throw new Exceptions\ArtistNotFoundException();;
|
||||
}
|
||||
|
||||
public function Create(): void{
|
||||
|
@ -141,7 +144,7 @@ class Artist extends Accessor{
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws \Exceptions\ValidationException
|
||||
* @throws Exceptions\ValidationException
|
||||
*/
|
||||
public static function GetOrCreate(Artist $artist): Artist{
|
||||
$result = Db::Query('
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue