mirror of
https://github.com/Karaka-Management/oms-Auditor.git
synced 2026-02-16 13:38:41 +00:00
implement immutable datetime
This commit is contained in:
parent
9720122c0c
commit
04f4f1a401
|
|
@ -109,7 +109,7 @@ class Audit
|
||||||
* @var \DateTime
|
* @var \DateTime
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private \DateTime $createdAt;
|
private \DateTimeImmutable $createdAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ip of creator.
|
* Ip of creator.
|
||||||
|
|
@ -145,7 +145,7 @@ class Audit
|
||||||
string $content = null,
|
string $content = null,
|
||||||
int $ip = 0
|
int $ip = 0
|
||||||
) {
|
) {
|
||||||
$this->createdAt = new \DateTime('now');
|
$this->createdAt = new \DateTimeImmutable('now');
|
||||||
$this->createdBy = $account ?? new NullAccount();
|
$this->createdBy = $account ?? new NullAccount();
|
||||||
$this->old = $old;
|
$this->old = $old;
|
||||||
$this->new = $new;
|
$this->new = $new;
|
||||||
|
|
@ -274,7 +274,7 @@ class Audit
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getCreatedAt() : \DateTime
|
public function getCreatedAt() : \DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ final class AuditMapper extends DataMapperAbstract
|
||||||
protected static array $columns = [
|
protected static array $columns = [
|
||||||
'auditor_audit_id' => ['name' => 'auditor_audit_id', 'type' => 'int', 'internal' => 'id'],
|
'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_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_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_module' => ['name' => 'auditor_audit_module', 'type' => 'string', 'internal' => 'module'],
|
||||||
'auditor_audit_ref' => ['name' => 'auditor_audit_ref', 'type' => 'string', 'internal' => 'ref'],
|
'auditor_audit_ref' => ['name' => 'auditor_audit_ref', 'type' => 'string', 'internal' => 'ref'],
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class AuditTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertNull($audit->getOld());
|
self::assertNull($audit->getOld());
|
||||||
self::assertNull($audit->getNew());
|
self::assertNull($audit->getNew());
|
||||||
self::assertEquals(0, $audit->getCreatedBy()->getId());
|
self::assertEquals(0, $audit->getCreatedBy()->getId());
|
||||||
self::assertInstanceOf('\DateTime', $audit->getCreatedAt());
|
self::assertInstanceOf('\DateTimeImmutable', $audit->getCreatedAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user