Commit 9aaf56c7 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

DateTimeAwareTrait

parent 61b80c67
Loading
Loading
Loading
Loading
+24 −0
Changes for module/Application/src/Application/Entity/DateTimeAwareTrait.php: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Entity;

use DateTime;
use Exception;
use UnicaenApp\Exception\RuntimeException;

trait DateTimeAwareTrait {

    /**
     * @return DateTime
     */
    public function getDateTime()
    {
        try {
            $date = new DateTime();
        } catch (Exception $e) {
            throw new RuntimeException("Un problème s'est produit lors de la récupération de la date", 0, $e);
        }

        return $date;
    }
}
 No newline at end of file