Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * Rating Repository Interface.
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @copyright 2025-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2025-11-19
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\Search\Rating;
21
22use phpMyFAQ\Entity\Vote;
23
24interface RatingRepositoryInterface
25{
26    /**
27     * Fetches the voting data for a given FAQ record.
28     *
29     * @return \stdClass|null Returns a row with 'voting' and 'usr' properties, or null if not found
30     */
31    public function fetchByRecordId(int $id): ?\stdClass;
32
33    /**
34     * Checks if a vote from this IP is allowed (not within 5 minutes).
35     */
36    public function isVoteAllowed(int $id, string $ip): bool;
37
38    /**
39     * Returns the number of users who voted for a record.
40     */
41    public function getNumberOfVotings(int $recordId): int;
42
43    /**
44     * Creates a new voting record.
45     */
46    public function create(Vote $vote): bool;
47
48    /**
49     * Updates an existing voting record.
50     */
51    public function update(Vote $vote): bool;
52
53    /**
54     * Deletes all votes.
55     */
56    public function deleteAll(): bool;
57}