mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 14:27:28 +01:00
38 lines
694 B
PHP
38 lines
694 B
PHP
|
<?php
|
||
|
|
||
|
namespace Infinito\Attribut;
|
||
|
|
||
|
use Infinito\Exception\AllreadySetException;
|
||
|
|
||
|
/**
|
||
|
* @author kevinfrantz
|
||
|
*
|
||
|
* @see TimestampAttributInterface
|
||
|
*/
|
||
|
trait TimestampAttribut
|
||
|
{
|
||
|
/**
|
||
|
* @var \DateTime
|
||
|
*/
|
||
|
protected $timestamp;
|
||
|
|
||
|
/**
|
||
|
* @param \DateTime $datetime
|
||
|
*/
|
||
|
public function setTimestamp(\DateTime $timestamp): void
|
||
|
{
|
||
|
if (isset($this->timestamp)) {
|
||
|
throw new AllreadySetException('The timestamp is allready set. An Update is not possible!');
|
||
|
}
|
||
|
$this->timestamp = $timestamp;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \DateTime
|
||
|
*/
|
||
|
public function getTimestamp(): \DateTime
|
||
|
{
|
||
|
return $this->timestamp;
|
||
|
}
|
||
|
}
|