| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * dmarc-srg - A php parser, viewer and summary report generator for incoming DMARC reports. |
| 5 | * Copyright (C) 2022-2023 Aleksey Andreev (liuch) |
| 6 | * |
| 7 | * Available at: |
| 8 | * https://github.com/liuch/dmarc-srg |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the Free |
| 12 | * Software Foundation, either version 3 of the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along with |
| 20 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | * |
| 22 | * ========================= |
| 23 | * |
| 24 | * This file contains the SettingMapperInterface |
| 25 | * |
| 26 | * @category API |
| 27 | * @package DmarcSrg |
| 28 | * @author Aleksey Andreev (liuch) |
| 29 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3 |
| 30 | */ |
| 31 | |
| 32 | namespace Liuch\DmarcSrg\Database; |
| 33 | |
| 34 | interface SettingMapperInterface |
| 35 | { |
| 36 | /** |
| 37 | * Returns setting value as a string by key |
| 38 | * |
| 39 | * @param string $key |
| 40 | * @param int $user_id |
| 41 | * |
| 42 | * @return string |
| 43 | */ |
| 44 | public function value(string $key, int $user_id): string; |
| 45 | |
| 46 | /** |
| 47 | * Returns a key-value array of the setting list like this: |
| 48 | * [ 'name1' => 'value1', 'name2' => 'value2' ] |
| 49 | * |
| 50 | * @param int $user_id User Id to get settings for |
| 51 | * |
| 52 | * @return array |
| 53 | */ |
| 54 | public function list(int $user_id): array; |
| 55 | |
| 56 | /** |
| 57 | * Saves the setting to the database |
| 58 | * |
| 59 | * Updates the value of the setting in the database if the setting exists there or insert a new record otherwise. |
| 60 | * |
| 61 | * @param string $name Setting name |
| 62 | * @param string $value Setting value |
| 63 | * @param int $user_id User Id to save the setting for |
| 64 | * |
| 65 | * @return void |
| 66 | */ |
| 67 | public function save(string $name, string $value, int $user_id): void; |
| 68 | } |