Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportOutputFactory
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 createReportOutput
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5class ReportOutputFactory
6{
7  public static function createReportOutput(
8    int $workspaceId,
9    array $dataIds,
10    ReportType $reportType,
11    ReportFormat $reportFormat
12  ): LogReportOutput | ResponseReportOutput | ReviewReportOutput | SysCheckReportOutput {
13    // TODO this union type instead of Report is used to satisfy mockery. Could not make it work to mock the child classes
14    // of this factory, that can dont need to be mocked in all their methods and at the same inherit the Report class
15    return match ($reportType) {
16      ReportType::LOG => new LogReportOutput($workspaceId, $dataIds, $reportFormat),
17      ReportType::RESPONSE => new ResponseReportOutput($workspaceId, $dataIds, $reportFormat),
18      ReportType::REVIEW => new ReviewReportOutput($workspaceId, $dataIds, $reportFormat),
19      ReportType::SYSCHECK => new SysCheckReportOutput($workspaceId, $dataIds, $reportFormat),
20    };
21  }
22}