openvk/Web/Models/Repositories/NoSpamLogs.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

39 lines
945 B
PHP

<?php
declare(strict_types=1);
namespace openvk\Web\Models\Repositories;
use Chandler\Database\DatabaseConnection;
use openvk\Web\Models\Entities\NoSpamLog;
use openvk\Web\Models\Entities\User;
use Nette\Database\Table\ActiveRow;
class NoSpamLogs
{
private $context;
private $noSpamLogs;
public function __construct()
{
$this->context = DatabaseConnection::i()->getContext();
$this->noSpamLogs = $this->context->table("noSpam_templates");
}
private function toNoSpamLog(?ActiveRow $ar): ?NoSpamLog
{
return is_null($ar) ? null : new NoSpamLog($ar);
}
public function get(int $id): ?NoSpamLog
{
return $this->toNoSpamLog($this->noSpamLogs->get($id));
}
public function getList(array $filter = []): \Traversable
{
foreach ($this->noSpamLogs->where($filter)->order("`id` DESC") as $log) {
yield new NoSpamLog($log);
}
}
}