openvk/Web/Models/Entities/Ban.php
Alexander Minkin 6ec54a379d
feat: add linting of code (#1220)
* feat(lint): add php-cs-fixer for linting

Removing previous CODE_STYLE as it was not enforced anyway and using PER-CS 2.0.

This is not the reformatting commit.

* style: format code according to PER-CS 2.0 with php-cs-fixer

* ci(actions): add lint action

Resolves #1132.
2025-01-31 18:20:13 +03:00

70 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace openvk\Web\Models\Entities;
use openvk\Web\Models\RowModel;
use openvk\Web\Util\DateTime;
use openvk\Web\Models\Repositories\{Users};
use Nette\Database\Table\ActiveRow;
class Ban extends RowModel
{
protected $tableName = "bans";
public function getId(): int
{
return $this->getRecord()->id;
}
public function getReason(): ?string
{
return $this->getRecord()->reason;
}
public function getUser(): ?User
{
return (new Users())->get($this->getRecord()->user);
}
public function getInitiator(): ?User
{
return (new Users())->get($this->getRecord()->initiator);
}
public function getStartTime(): int
{
return $this->getRecord()->iat;
}
public function getEndTime(): int
{
return $this->getRecord()->exp;
}
public function getTime(): int
{
return $this->getRecord()->time;
}
public function isPermanent(): bool
{
return $this->getEndTime() === 0;
}
public function isRemovedManually(): bool
{
return (bool) $this->getRecord()->removed_manually;
}
public function isOver(): bool
{
return $this->isRemovedManually();
}
public function whoRemoved(): ?User
{
return (new Users())->get($this->getRecord()->removed_by);
}
}