Fix PHPStan errors

This commit is contained in:
Mike Colagrosso 2024-05-20 20:37:25 -06:00 committed by Alex Cabal
parent 79daa82bf4
commit 72d679a04f
12 changed files with 53 additions and 0 deletions

View file

@ -580,6 +580,10 @@ class Ebook{
// METHODS
// *******
/**
* @throws \Exception
* @throws \Exceptions\ValidationException
*/
public function Validate(): void{
$now = new DateTimeImmutable();
$error = new Exceptions\ValidationException();
@ -739,6 +743,9 @@ class Ebook{
}
}
/**
* @throws \Exception
*/
public function CreateOrUpdate(): void{
try{
$existingEbook = Ebook::GetByIdentifier($this->Identifier);
@ -750,6 +757,9 @@ class Ebook{
}
}
/**
* @throws \Exceptions\ValidationException
*/
private function InsertTagStrings(): void{
$tags = [];
foreach($this->Tags as $ebookTag){
@ -758,6 +768,9 @@ class Ebook{
$this->Tags = $tags;
}
/**
* @throws \Exceptions\ValidationException
*/
private function InsertLocSubjectStrings(): void{
$subjects = [];
foreach($this->LocSubjects as $locSubject){
@ -1089,6 +1102,9 @@ class Ebook{
return $result[0];
}
/**
* @throws \Exception
*/
public function Create(): void{
$this->Validate();
@ -1140,6 +1156,9 @@ class Ebook{
$this->InsertTocEntries();
}
/**
* @throws \Exception
*/
public function Save(): void{
$this->Validate();

View file

@ -22,6 +22,10 @@ class EbookTag extends Tag{
// *******
// METHODS
// *******
/**
* @throws \Exceptions\ValidationException
*/
public function Validate(): void{
$error = new Exceptions\ValidationException();
@ -34,6 +38,9 @@ class EbookTag extends Tag{
}
}
/**
* @throws \Exceptions\ValidationException
*/
public function Create(): void{
$this->Validate();
@ -44,6 +51,9 @@ class EbookTag extends Tag{
$this->TagId = Db::GetLastInsertedId();
}
/**
* @throws \Exceptions\ValidationException
*/
public function GetByNameOrCreate(string $name): EbookTag{
$result = Db::Query('
SELECT *

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class EbookDescriptionRequiredException extends AppException{
/** @var string $message */
protected $message = 'Ebook Description required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class EbookIdentifierRequiredException extends AppException{
/** @var string $message */
protected $message = 'Ebook Identifier required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class EbookIndexableTextRequiredException extends AppException{
/** @var string $message */
protected $message = 'Ebook IndexableText required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class EbookLongDescriptionRequiredException extends AppException{
/** @var string $message */
protected $message = 'Ebook LongDescription required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class EbookTitleRequiredException extends AppException{
/** @var string $message */
protected $message = 'Ebook Title required.';
}

View file

@ -4,8 +4,12 @@ namespace Exceptions;
use Safe\DateTimeImmutable;
class InvalidEbookCreatedDatetimeException extends AppException{
/** @var string $message */
protected $message = 'Invalid EbookCreated datetime.';
/**
* @throws \Exception
*/
public function __construct(DateTimeImmutable $createdDatetime){
$now = new DateTimeImmutable();
$this->message = 'Invalid EbookCreated datetime. ' . $createdDatetime->format('Y-m-d') . ' is not between ' . EBOOK_EARLIEST_CREATION_DATE->format('Y-m-d') . ' and ' . $now->format('Y-m-d') . '.';

View file

@ -4,6 +4,7 @@ namespace Exceptions;
use Safe\DateTimeImmutable;
class InvalidEbookRepoFilesystemPathException extends AppException{
/** @var string $message */
protected $message = 'Invalid RepoFilesystemPath.';
public function __construct(?string $path){

View file

@ -4,8 +4,12 @@ namespace Exceptions;
use Safe\DateTimeImmutable;
class InvalidEbookUpdatedDatetimeException extends AppException{
/** @var string $message */
protected $message = 'Invalid EbookUpdated datetime.';
/**
* @throws \Exception
*/
public function __construct(DateTimeImmutable $updatedDatetime){
$now = new DateTimeImmutable();
$this->message = 'Invalid EbookUpdated datetime. ' . $updatedDatetime->format('Y-m-d') . ' is not between ' . EBOOK_EARLIEST_CREATION_DATE->format('Y-m-d') . ' and ' . $now->format('Y-m-d') . '.';

View file

@ -4,6 +4,7 @@ namespace Exceptions;
use Safe\DateTimeImmutable;
class InvalidEbookWwwFilesystemPathException extends AppException{
/** @var string $message */
protected $message = 'Invalid WwwFilesystemPath.';
public function __construct(?string $path){

View file

@ -2,6 +2,9 @@
class LocSubject extends Tag{
public int $LocSubjectId;
/**
* @throws \Exceptions\ValidationException
*/
public function Validate(): void{
$error = new Exceptions\ValidationException();
@ -14,6 +17,9 @@ class LocSubject extends Tag{
}
}
/**
* @throws \Exceptions\ValidationException
*/
public function Create(): void{
$this->Validate();
@ -24,6 +30,9 @@ class LocSubject extends Tag{
$this->LocSubjectId = Db::GetLastInsertedId();
}
/**
* @throws \Exceptions\ValidationException
*/
public function GetByNameOrCreate(string $name): LocSubject{
$result = Db::Query('
SELECT *