Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportIncidentManager
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 record
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 notify
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\ReportIncident\Services;
4
5use MediaWiki\Extension\ReportIncident\IncidentReport;
6use MediaWiki\Extension\ReportIncident\IncidentReportEmailStatus;
7use StatusValue;
8
9/**
10 * Manage IncidentReport objects and do things:
11 * - Email recipients with the report contents
12 * - ...
13 */
14class ReportIncidentManager {
15    private ReportIncidentMailer $incidentMailer;
16
17    /**
18     * @param ReportIncidentMailer $incidentMailer
19     */
20    public function __construct( ReportIncidentMailer $incidentMailer ) {
21        $this->incidentMailer = $incidentMailer;
22    }
23
24    /**
25     * @param IncidentReport $incidentReport
26     * @return StatusValue
27     */
28    public function record( IncidentReport $incidentReport ): StatusValue {
29        // For now, this is a no-op.
30        // Eventually we would store the reports in DB (T345246)
31        return StatusValue::newGood();
32    }
33
34    /**
35     * @param IncidentReport $incidentReport
36     * @return IncidentReportEmailStatus
37     */
38    public function notify( IncidentReport $incidentReport ): StatusValue {
39        return $this->incidentMailer->sendEmail( $incidentReport );
40    }
41
42}