Debian Codegraph @

classes/Database/ReportMapperInterface.php

raw symbols SCIP
1 <?php
2
3 /**
4 * dmarc-srg - A php parser, viewer and summary report generator for incoming DMARC reports.
5 * Copyright (C) 2022-2024 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 ReportMapperInterface
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 use Liuch\DmarcSrg\Report\ReportData;
35
36 interface ReportMapperInterface
37 {
38 /**
39 * Fetches report data from the database and stores it in the passed array
40 *
41 * @param ReportData $data Report data class.
42 * To identify the report it must contain at least these fields:
43 * `report_id` - External report id from the xml file
44 * `domain` - Fully Qualified Domain Name without a trailing dot
45 * `org_name` - Organization name
46 * `date=>begin` - Begin timestamp of the report time range
47 *
48 * @return void
49 */
50 public function fetch($data): void;
51
52 /**
53 * Inserts report data into the database.
54 *
55 * @param ReportData $data Report data
56 *
57 * @return void
58 */
59 public function save($data): void;
60
61 /**
62 * Sets report record property in database.
63 *
64 * It has nothing to do with the fields of the report itself.
65 *
66 * @param ReportData $data Report data.
67 * @param string $name Name of property to change. Currently only `seen` is supported.
68 * @param mixed $value New property value
69 *
70 * @return void
71 */
72 public function setProperty($data, string $name, $value): void;
73
74 /**
75 * Returns a list of reports with specified parameters
76 *
77 * This method returns a list of reports that depends on the $filter, $order and $limit.
78 *
79 * @param array $filter Key-value array with filtering parameters
80 * @param array $order Key-value array:
81 * 'field' => string, 'begin_time'
82 * 'direction' => string, 'ascent' or 'descent'
83 * @param array $limit Key-value array with two keys: `offset` and `count`
84 * @param int $user_id User ID to retrieve the list for
85 *
86 * @return array
87 */
88 public function list(array &$filter, array &$order, array &$limit, int $user_id): array;
89
90 /**
91 * Returns the number of reports matching the specified filter and limits
92 *
93 * @param array $filter Key-value array with filtering parameters
94 * @param array $limit Key-value array with two keys: `offset` and `count`
95 * @param int $user_id User ID to count reports for
96 *
97 * @return int
98 */
99 public function count(array &$filter, array &$limit, int $user_id): int;
100
101 /**
102 * Deletes reports from the database
103 *
104 * It deletes repors form the database. The filter options `dkim` and `spf` do not affect this.
105 *
106 * @param array $filter Key-value array with filtering parameters
107 * @param array $order Key-value array:
108 * 'field' => string, 'begin_time'
109 * 'direction' => string, 'ascent' or 'descent'
110 * @param array $limit Key-value array with two keys: `offset` and `count`
111 *
112 * @return void
113 */
114 public function delete(array &$filter, array &$order, array &$limit): void;
115
116 /**
117 * Returns a list of months with years of the form: 'yyyy-mm' for which there is at least one report
118 *
119 * @param int $user_id User ID to retrieve the list for
120 *
121 * @return array
122 */
123 public function months(int $user_id): array;
124
125 /**
126 * Returns a list of reporting organizations from which there is at least one report
127 *
128 * @param int $user_id User ID to retrieve the list for
129 *
130 * @return array
131 */
132 public function organizations(int $user_id): array;
133 }