for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Linna Framework.
*
* @author Sebastian Rapetti <[email protected]>
* @copyright (c) 2018, Sebastian Rapetti
* @license http://opensource.org/licenses/MIT MIT License
*/
declare(strict_types=1);
namespace Linna\DataMapper;
use UnexpectedValueException;
* Provide methods and properties for track the creation and updates of the
* domain objects.
trait DomainObjectTimeTrait
{
* @var string Insertion date on persistent storage.
public string $created = '';
* @var string Last update date on persistento storage.
public string $lastUpdate = '';
* Set the creation date for the object.
* @return void
* @throws UnexpectedValueException If the creation date on the object is already set.
public function setCreated(): void
$date = \date(DATE_ATOM);
if ($this->created !== '') {
throw new UnexpectedValueException('Creation date property is immutable.');
}
$this->created = $date;
* Set the time for the last object changes.
public function setLastUpdate(): void
$this->lastUpdate = $date;