This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Dao/EntityConverters/AbstractEntityConverter.php
Marcin Kurczewski 632bac8661 Added "use ..." statements
This version ditches backwards compatibility with PHP earlier than 5.6.
2014-10-18 18:48:36 +02:00

35 lines
709 B
PHP

<?php
namespace Szurubooru\Dao\EntityConverters;
abstract class AbstractEntityConverter implements IEntityConverter
{
private $entityDecorator = null;
public function setEntityDecorator(callable $entityDecorator)
{
$this->entityDecorator = $entityDecorator;
}
public function toEntity(array $array)
{
$entity = $this->toBasicEntity($array);
$func = $this->entityDecorator;
if ($func !== null)
$func($entity);
return $entity;
}
protected abstract function toBasicEntity(array $array);
protected function dbTimeToEntityTime($time)
{
if ($time === null)
return null;
return date('c', strtotime($time));
}
protected function entityTimeToDbTime($time)
{
return $time;
}
}