Use the NOW constant from eec7971

This commit is contained in:
Mike Colagrosso 2024-10-23 17:10:53 -06:00 committed by Alex Cabal
parent df8eac6f82
commit 65d1dcdd88
6 changed files with 6 additions and 21 deletions

View file

@ -31,9 +31,6 @@ class Contributor{
* @throws Exceptions\ValidationException
*/
public function Validate(): void{
/** @throws void */
$now = new DateTimeImmutable();
$error = new Exceptions\ValidationException();
if(!isset($this->EbookId)){

View file

@ -939,9 +939,6 @@ class Ebook{
* @throws Exceptions\ValidationException
*/
public function Validate(): void{
/** @throws void */
$now = new DateTimeImmutable();
$error = new Exceptions\ValidationException();
if(isset($this->Identifier)){
@ -1208,7 +1205,7 @@ class Ebook{
}
if(isset($this->EbookCreated)){
if($this->EbookCreated > $now){
if($this->EbookCreated > NOW){
$error->Add(new Exceptions\InvalidEbookCreatedDatetimeException($this->EbookCreated));
}
}
@ -1217,7 +1214,7 @@ class Ebook{
}
if(isset($this->EbookUpdated)){
if($this->EbookUpdated > $now){
if($this->EbookUpdated > NOW){
$error->Add(new Exceptions\InvalidEbookUpdatedDatetimeException($this->EbookUpdated));
}

View file

@ -8,8 +8,6 @@ class InvalidEbookCreatedDatetimeException extends AppException{
protected $message = 'Invalid EbookCreated datetime.';
public function __construct(DateTimeImmutable $createdDatetime){
/** @throws void */
$now = new DateTimeImmutable();
$this->message = 'Invalid EbookCreated datetime. ' . $createdDatetime->format('Y-m-d') . ' is after ' . $now->format('Y-m-d') . '.';
$this->message = 'Invalid EbookCreated datetime. ' . $createdDatetime->format('Y-m-d') . ' is after ' . NOW->format('Y-m-d') . '.';
}
}

View file

@ -8,8 +8,6 @@ class InvalidEbookUpdatedDatetimeException extends AppException{
protected $message = 'Invalid EbookUpdated datetime.';
public function __construct(DateTimeImmutable $updatedDatetime){
/** @throws void */
$now = new DateTimeImmutable();
$this->message = 'Invalid EbookUpdated datetime. ' . $updatedDatetime->format('Y-m-d') . ' is after ' . $now->format('Y-m-d') . '.';
$this->message = 'Invalid EbookUpdated datetime. ' . $updatedDatetime->format('Y-m-d') . ' is after ' . NOW->format('Y-m-d') . '.';
}
}

View file

@ -8,8 +8,6 @@ class InvalidGitCommitCreatedDatetimeException extends AppException{
protected $message = 'Invalid GitCommit Created datetime.';
public function __construct(DateTimeImmutable $createdDatetime){
/** @throws void */
$now = new DateTimeImmutable();
$this->message = 'Invalid GitCommit Created datetime. ' . $createdDatetime->format('Y-m-d') . ' is after ' . $now->format('Y-m-d') . '.';
$this->message = 'Invalid GitCommit Created datetime. ' . $createdDatetime->format('Y-m-d') . ' is after ' . NOW->format('Y-m-d') . '.';
}
}

View file

@ -30,9 +30,6 @@ class GitCommit{
* @throws Exceptions\ValidationException
*/
public function Validate(): void{
/** @throws void */
$now = new DateTimeImmutable();
$error = new Exceptions\ValidationException();
if(!isset($this->EbookId)){
@ -40,7 +37,7 @@ class GitCommit{
}
if(isset($this->Created)){
if($this->Created > $now){
if($this->Created > NOW){
$error->Add(new Exceptions\InvalidGitCommitCreatedDatetimeException($this->Created));
}
}