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
|
// METHODS
|
||||||
// *******
|
// *******
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function Validate(): void{
|
public function Validate(): void{
|
||||||
$now = new DateTimeImmutable();
|
$now = new DateTimeImmutable();
|
||||||
$error = new Exceptions\ValidationException();
|
$error = new Exceptions\ValidationException();
|
||||||
|
@ -739,6 +743,9 @@ class Ebook{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function CreateOrUpdate(): void{
|
public function CreateOrUpdate(): void{
|
||||||
try{
|
try{
|
||||||
$existingEbook = Ebook::GetByIdentifier($this->Identifier);
|
$existingEbook = Ebook::GetByIdentifier($this->Identifier);
|
||||||
|
@ -750,6 +757,9 @@ class Ebook{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
private function InsertTagStrings(): void{
|
private function InsertTagStrings(): void{
|
||||||
$tags = [];
|
$tags = [];
|
||||||
foreach($this->Tags as $ebookTag){
|
foreach($this->Tags as $ebookTag){
|
||||||
|
@ -758,6 +768,9 @@ class Ebook{
|
||||||
$this->Tags = $tags;
|
$this->Tags = $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
private function InsertLocSubjectStrings(): void{
|
private function InsertLocSubjectStrings(): void{
|
||||||
$subjects = [];
|
$subjects = [];
|
||||||
foreach($this->LocSubjects as $locSubject){
|
foreach($this->LocSubjects as $locSubject){
|
||||||
|
@ -1089,6 +1102,9 @@ class Ebook{
|
||||||
return $result[0];
|
return $result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function Create(): void{
|
public function Create(): void{
|
||||||
$this->Validate();
|
$this->Validate();
|
||||||
|
|
||||||
|
@ -1140,6 +1156,9 @@ class Ebook{
|
||||||
$this->InsertTocEntries();
|
$this->InsertTocEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function Save(): void{
|
public function Save(): void{
|
||||||
$this->Validate();
|
$this->Validate();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ class EbookTag extends Tag{
|
||||||
// *******
|
// *******
|
||||||
// METHODS
|
// METHODS
|
||||||
// *******
|
// *******
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function Validate(): void{
|
public function Validate(): void{
|
||||||
$error = new Exceptions\ValidationException();
|
$error = new Exceptions\ValidationException();
|
||||||
|
|
||||||
|
@ -34,6 +38,9 @@ class EbookTag extends Tag{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function Create(): void{
|
public function Create(): void{
|
||||||
$this->Validate();
|
$this->Validate();
|
||||||
|
|
||||||
|
@ -44,6 +51,9 @@ class EbookTag extends Tag{
|
||||||
$this->TagId = Db::GetLastInsertedId();
|
$this->TagId = Db::GetLastInsertedId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function GetByNameOrCreate(string $name): EbookTag{
|
public function GetByNameOrCreate(string $name): EbookTag{
|
||||||
$result = Db::Query('
|
$result = Db::Query('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
namespace Exceptions;
|
namespace Exceptions;
|
||||||
|
|
||||||
class EbookDescriptionRequiredException extends AppException{
|
class EbookDescriptionRequiredException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Ebook Description required.';
|
protected $message = 'Ebook Description required.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
namespace Exceptions;
|
namespace Exceptions;
|
||||||
|
|
||||||
class EbookIdentifierRequiredException extends AppException{
|
class EbookIdentifierRequiredException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Ebook Identifier required.';
|
protected $message = 'Ebook Identifier required.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
namespace Exceptions;
|
namespace Exceptions;
|
||||||
|
|
||||||
class EbookIndexableTextRequiredException extends AppException{
|
class EbookIndexableTextRequiredException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Ebook IndexableText required.';
|
protected $message = 'Ebook IndexableText required.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
namespace Exceptions;
|
namespace Exceptions;
|
||||||
|
|
||||||
class EbookLongDescriptionRequiredException extends AppException{
|
class EbookLongDescriptionRequiredException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Ebook LongDescription required.';
|
protected $message = 'Ebook LongDescription required.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
namespace Exceptions;
|
namespace Exceptions;
|
||||||
|
|
||||||
class EbookTitleRequiredException extends AppException{
|
class EbookTitleRequiredException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Ebook Title required.';
|
protected $message = 'Ebook Title required.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,12 @@ namespace Exceptions;
|
||||||
use Safe\DateTimeImmutable;
|
use Safe\DateTimeImmutable;
|
||||||
|
|
||||||
class InvalidEbookCreatedDatetimeException extends AppException{
|
class InvalidEbookCreatedDatetimeException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Invalid EbookCreated datetime.';
|
protected $message = 'Invalid EbookCreated datetime.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function __construct(DateTimeImmutable $createdDatetime){
|
public function __construct(DateTimeImmutable $createdDatetime){
|
||||||
$now = new DateTimeImmutable();
|
$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') . '.';
|
$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;
|
use Safe\DateTimeImmutable;
|
||||||
|
|
||||||
class InvalidEbookRepoFilesystemPathException extends AppException{
|
class InvalidEbookRepoFilesystemPathException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Invalid RepoFilesystemPath.';
|
protected $message = 'Invalid RepoFilesystemPath.';
|
||||||
|
|
||||||
public function __construct(?string $path){
|
public function __construct(?string $path){
|
||||||
|
|
|
@ -4,8 +4,12 @@ namespace Exceptions;
|
||||||
use Safe\DateTimeImmutable;
|
use Safe\DateTimeImmutable;
|
||||||
|
|
||||||
class InvalidEbookUpdatedDatetimeException extends AppException{
|
class InvalidEbookUpdatedDatetimeException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Invalid EbookUpdated datetime.';
|
protected $message = 'Invalid EbookUpdated datetime.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function __construct(DateTimeImmutable $updatedDatetime){
|
public function __construct(DateTimeImmutable $updatedDatetime){
|
||||||
$now = new DateTimeImmutable();
|
$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') . '.';
|
$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;
|
use Safe\DateTimeImmutable;
|
||||||
|
|
||||||
class InvalidEbookWwwFilesystemPathException extends AppException{
|
class InvalidEbookWwwFilesystemPathException extends AppException{
|
||||||
|
/** @var string $message */
|
||||||
protected $message = 'Invalid WwwFilesystemPath.';
|
protected $message = 'Invalid WwwFilesystemPath.';
|
||||||
|
|
||||||
public function __construct(?string $path){
|
public function __construct(?string $path){
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
class LocSubject extends Tag{
|
class LocSubject extends Tag{
|
||||||
public int $LocSubjectId;
|
public int $LocSubjectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function Validate(): void{
|
public function Validate(): void{
|
||||||
$error = new Exceptions\ValidationException();
|
$error = new Exceptions\ValidationException();
|
||||||
|
|
||||||
|
@ -14,6 +17,9 @@ class LocSubject extends Tag{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function Create(): void{
|
public function Create(): void{
|
||||||
$this->Validate();
|
$this->Validate();
|
||||||
|
|
||||||
|
@ -24,6 +30,9 @@ class LocSubject extends Tag{
|
||||||
$this->LocSubjectId = Db::GetLastInsertedId();
|
$this->LocSubjectId = Db::GetLastInsertedId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exceptions\ValidationException
|
||||||
|
*/
|
||||||
public function GetByNameOrCreate(string $name): LocSubject{
|
public function GetByNameOrCreate(string $name): LocSubject{
|
||||||
$result = Db::Query('
|
$result = Db::Query('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue