mirror of
https://github.com/openvk/openvk
synced 2025-02-02 21:15:42 +03:00
Alexander Minkin
6ec54a379d
* 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.
39 lines
945 B
PHP
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);
|
|
}
|
|
}
|
|
}
|