diff --git a/Models/Audit.php b/Models/Audit.php index 04df210..f442e22 100755 --- a/Models/Audit.php +++ b/Models/Audit.php @@ -109,7 +109,7 @@ class Audit * @var \DateTime * @since 1.0.0 */ - private \DateTime $createdAt; + private \DateTimeImmutable $createdAt; /** * Ip of creator. @@ -145,7 +145,7 @@ class Audit string $content = null, int $ip = 0 ) { - $this->createdAt = new \DateTime('now'); + $this->createdAt = new \DateTimeImmutable('now'); $this->createdBy = $account ?? new NullAccount(); $this->old = $old; $this->new = $new; @@ -274,7 +274,7 @@ class Audit * * @since 1.0.0 */ - public function getCreatedAt() : \DateTime + public function getCreatedAt() : \DateTimeInterface { return $this->createdAt; } diff --git a/Models/AuditMapper.php b/Models/AuditMapper.php index 7439999..452154e 100755 --- a/Models/AuditMapper.php +++ b/Models/AuditMapper.php @@ -36,7 +36,7 @@ final class AuditMapper extends DataMapperAbstract protected static array $columns = [ 'auditor_audit_id' => ['name' => 'auditor_audit_id', 'type' => 'int', 'internal' => 'id'], 'auditor_audit_created_by' => ['name' => 'auditor_audit_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], - 'auditor_audit_created_at' => ['name' => 'auditor_audit_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], + 'auditor_audit_created_at' => ['name' => 'auditor_audit_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], 'auditor_audit_ip' => ['name' => 'auditor_audit_ip', 'type' => 'int', 'internal' => 'ip', 'annotations' => ['gdpr' => true]], 'auditor_audit_module' => ['name' => 'auditor_audit_module', 'type' => 'string', 'internal' => 'module'], 'auditor_audit_ref' => ['name' => 'auditor_audit_ref', 'type' => 'string', 'internal' => 'ref'], diff --git a/tests/Models/AuditTest.php b/tests/Models/AuditTest.php index e641847..d9d7a5f 100755 --- a/tests/Models/AuditTest.php +++ b/tests/Models/AuditTest.php @@ -41,7 +41,7 @@ class AuditTest extends \PHPUnit\Framework\TestCase self::assertNull($audit->getOld()); self::assertNull($audit->getNew()); self::assertEquals(0, $audit->getCreatedBy()->getId()); - self::assertInstanceOf('\DateTime', $audit->getCreatedAt()); + self::assertInstanceOf('\DateTimeImmutable', $audit->getCreatedAt()); } /**