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/ScoreEntityConverter.php

31 lines
959 B
PHP
Raw Normal View History

2014-09-28 15:21:25 +02:00
<?php
namespace Szurubooru\Dao\EntityConverters;
use Szurubooru\Entities\Entity;
use Szurubooru\Entities\Score;
2014-09-28 15:21:25 +02:00
class ScoreEntityConverter extends AbstractEntityConverter implements IEntityConverter
2014-09-28 15:21:25 +02:00
{
2015-06-28 10:07:11 +02:00
public function toBasicArray(Entity $entity)
{
return
[
'userId' => $entity->getUserId(),
'postId' => $entity->getPostId(),
'commentId' => $entity->getCommentId(),
'time' => $this->entityTimeToDbTime($entity->getTime()),
'score' => $entity->getScore(),
];
}
2014-09-28 15:21:25 +02:00
2015-06-28 10:07:11 +02:00
public function toBasicEntity(array $array)
{
$entity = new Score(intval($array['id']));
$entity->setUserId($array['userId']);
$entity->setPostId($array['postId']);
$entity->setCommentId($array['commentId']);
$entity->setTime($this->dbTimeToEntityTime($array['time']));
$entity->setScore(intval($array['score']));
return $entity;
}
2014-09-28 15:21:25 +02:00
}