eugene-matvejev/battleship-game-api

View on GitHub
src/FoundationBundle/ORM/TimestampedTrait.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace EM\FoundationBundle\ORM;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;

/**
 * @see   TimestampedTraitTest
 *
 * @since 1.0
 */
trait TimestampedTrait
{
    /**
     * @ORM\Column(name="timestamp", type="datetime")
     *
     * @JMS\Type("DateTime")
     *
     * @var \DateTime
     */
    protected $timestamp;

    public function getTimestamp() : \DateTime
    {
        return $this->timestamp;
    }

    /**
     * @ORM\PrePersist
     */
    public function setTimestamp() : self
    {
        $this->timestamp = new \DateTime();

        return $this;
    }
}