mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 15:20:32 -04:00
Fix PHPStan errors
This commit is contained in:
parent
79daa82bf4
commit
72d679a04f
12 changed files with 53 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
namespace Exceptions;
|
||||
|
||||
class EbookDescriptionRequiredException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Ebook Description required.';
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
namespace Exceptions;
|
||||
|
||||
class EbookIdentifierRequiredException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Ebook Identifier required.';
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
namespace Exceptions;
|
||||
|
||||
class EbookIndexableTextRequiredException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Ebook IndexableText required.';
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
namespace Exceptions;
|
||||
|
||||
class EbookLongDescriptionRequiredException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Ebook LongDescription required.';
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
namespace Exceptions;
|
||||
|
||||
class EbookTitleRequiredException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Ebook Title required.';
|
||||
}
|
||||
|
|
|
@ -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') . '.';
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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') . '.';
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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 *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue