Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
12 / 16
88.89% covered (warning)
88.89%
8 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
Report
75.00% covered (warning)
75.00%
12 / 16
88.89% covered (warning)
88.89%
8 / 9
12.89
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 generate
n/a
0 / 0
n/a
0 / 0
0
 getWorkspaceId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDataIds
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFormat
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAdminDAOInstance
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 setSysChecksFolderInstance
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 getCsvReportData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 asString
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getReportData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5abstract class Report {
6
7  protected const string BOM = "\xEF\xBB\xBF";         // UTF-8 BOM for MS Excel
8  protected const string DELIMITER = ';';              // standard delimiter for MS Excel
9  protected const string ENCLOSURE = '"';
10  protected const string LINE_ENDING = "\n";
11  protected const string CSV_CELL_FORMAT = self::ENCLOSURE . "%s" . self::ENCLOSURE;
12
13  protected int $workspaceId;
14  protected array $dataIds;
15  protected ReportFormat $format;
16  protected AdminDAO $adminDAO;
17  protected SysChecksFolder $sysChecksFolder;
18
19  protected string $csvReportData;
20  protected array $reportData;
21  protected bool $useNewVersion = false;
22
23  function __construct(int $workspaceId, array $dataIds, ReportFormat $reportFormat) {
24    $this->workspaceId = $workspaceId;
25    $this->dataIds = $dataIds;
26    $this->format = $reportFormat;
27  }
28
29  abstract public function generate(bool $useNewVersion = false): bool;
30
31  public function getWorkspaceId(): int {
32    return $this->workspaceId;
33  }
34
35  public function getDataIds(): array {
36    return $this->dataIds;
37  }
38
39  public function getFormat(): ReportFormat {
40    return $this->format;
41  }
42
43  public function setAdminDAOInstance(AdminDAO $adminDAO): void {
44    if (!isset($this->adminDAO)) {
45      $this->adminDAO = $adminDAO;
46    }
47  }
48
49  public function setSysChecksFolderInstance(SysChecksFolder $sysChecksFolder): void {
50    if (!isset($this->sysChecksFolder)) {
51      $this->sysChecksFolder = $sysChecksFolder;
52    }
53  }
54
55  public function getCsvReportData(): string {
56    return $this->csvReportData;
57  }
58
59  public function asString(): string {
60    return match ($this->format) {
61      ReportFormat::CSV => $this->csvReportData,
62      ReportFormat::JSON => json_encode($this->reportData)
63    };
64  }
65
66  public function getReportData(): array {
67    return $this->reportData;
68  }
69}