Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Preference\Domain\Repository;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Core\Preference\Domain\Model\PreferenceScope;
12use App\Core\Preference\Domain\Model\UserPreference;
13
14/**
15 * Domain Repository Contract for User Preferences persistence.
16 *
17 * @package App\Core\Preference\Domain\Repository
18 */
19interface UserPreferenceRepositoryInterface
20{
21    /**
22     * Saves or updates a user preference.
23     *
24     * @param UserPreference $preference The preference aggregate to persist.
25     * @return void
26     */
27    public function save(UserPreference $preference): void;
28
29    /**
30     * Finds a preference value for an exact scope coordinate.
31     *
32     * @param PreferenceScope $scope Target scope coordinate.
33     * @param string          $key   Preference key name.
34     * @return mixed Found preference value or null if not set.
35     */
36    public function findValue(PreferenceScope $scope, string $key): mixed;
37
38    /**
39     * Retrieves all preferences matching a given user and optional module.
40     *
41     * @param int         $userId            Target user ID.
42     * @param string|null $moduleName        Optional module filter.
43     * @param string|null $deviceFingerprint Optional device fingerprint filter.
44     * @return array<string, mixed> Key-value map of preferences.
45     */
46    public function findAllByUser(int $userId, ?string $moduleName = null, ?string $deviceFingerprint = null): array;
47
48    /**
49     * Deletes user preferences by scope and optional key.
50     *
51     * @param PreferenceScope $scope Scope defining target user/device/module.
52     * @param string|null     $key   Optional key to delete (null deletes all within scope).
53     * @return int Number of deleted records.
54     */
55    public function deleteByScope(PreferenceScope $scope, ?string $key = null): int;
56}