113 lines
2.2 KiB
PHP
113 lines
2.2 KiB
PHP
<?php namespace MapGuesser\PersistentData\Model;
|
|
|
|
use DateTime;
|
|
|
|
class Challenge extends Model
|
|
{
|
|
protected static string $table = 'challenges';
|
|
|
|
protected static array $fields = ['token', 'time_limit', 'time_limit_type', 'no_move', 'no_pan', 'no_zoom', 'created'];
|
|
|
|
protected static array $relations = [];
|
|
|
|
private int $token;
|
|
|
|
private ?int $timeLimit = null;
|
|
|
|
private static array $timeLimitTypes = ['game', 'round'];
|
|
|
|
private string $timeLimitType = 'game';
|
|
|
|
private bool $noMove = false;
|
|
|
|
private bool $noPan = false;
|
|
|
|
private bool $noZoom = false;
|
|
|
|
private DateTime $created;
|
|
|
|
public function setToken(int $token): void
|
|
{
|
|
$this->token = $token;
|
|
}
|
|
|
|
public function setTimeLimit(?int $timeLimit): void
|
|
{
|
|
if (isset($timeLimit)) {
|
|
$this->timeLimit = $timeLimit;
|
|
}
|
|
}
|
|
|
|
public function setTimeLimitType(string $timeLimitType): void
|
|
{
|
|
if (in_array($timeLimitType, self::$timeLimitTypes)) {
|
|
$this->timeLimitType = $timeLimitType;
|
|
}
|
|
}
|
|
|
|
public function setNoMove(bool $noMove): void
|
|
{
|
|
$this->noMove = $noMove;
|
|
}
|
|
|
|
public function setNoPan(bool $noPan): void
|
|
{
|
|
$this->noPan = $noPan;
|
|
}
|
|
|
|
public function setNoZoom(bool $noZoom): void
|
|
{
|
|
$this->noZoom = $noZoom;
|
|
}
|
|
|
|
public function setCreatedDate(DateTime $created): void
|
|
{
|
|
$this->created = $created;
|
|
}
|
|
|
|
public function setCreated(string $created): void
|
|
{
|
|
$this->created = new DateTime($created);
|
|
}
|
|
|
|
public function getToken(): int
|
|
{
|
|
return $this->token;
|
|
}
|
|
|
|
public function getTimeLimit(): ?int
|
|
{
|
|
return $this->timeLimit;
|
|
}
|
|
|
|
public function getTimeLimitType(): string
|
|
{
|
|
return $this->timeLimitType;
|
|
}
|
|
|
|
public function getNoMove(): bool
|
|
{
|
|
return $this->noMove;
|
|
}
|
|
|
|
public function getNoPan(): bool
|
|
{
|
|
return $this->noPan;
|
|
}
|
|
|
|
public function getNoZoom(): bool
|
|
{
|
|
return $this->noZoom;
|
|
}
|
|
|
|
public function getCreatedDate(): DateTime
|
|
{
|
|
return $this->created;
|
|
}
|
|
|
|
public function getCreated(): string
|
|
{
|
|
return $this->created->format('Y-m-d H:i:s');
|
|
}
|
|
}
|