context = DB::i()->getContext(); $this->bans = $this->context->table("bans"); } function toBan(?ActiveRow $ar): ?Ban { return is_null($ar) ? NULL : new Ban($ar); } function get(int $id): ?Ban { return $this->toBan($this->bans->get($id)); } function getByUser(int $user_id): \Traversable { foreach ($this->bans->where("user", $user_id) as $ban) yield new Ban($ban); } }