Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
62.96% covered (warning)
62.96%
34 / 54
73.91% covered (warning)
73.91%
17 / 23
CRAP
0.00% covered (danger)
0.00%
0 / 1
FileData
62.96% covered (warning)
62.96%
34 / 54
73.91% covered (warning)
73.91%
17 / 23
60.34
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
1 / 1
1
 getType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLabel
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDescription
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRelations
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isValid
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getValidationReport
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setValidationReport
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getModificationTime
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContextData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setContextData
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getVeronaModuleType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVeronaModuleId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVersionMayor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVersionMinor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVersionPatch
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVersionLabel
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVeronaVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 removeDeprecatedValues
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2declare(strict_types=1);
3
4class FileData extends DataCollectionTypeSafe {
5  protected string|null $type = null;
6  protected string $path = '';
7  protected string $id = '';
8  protected string $label = '';
9  protected string $description = '';
10  protected array $relations = [];
11  private bool $isValid;
12  protected array $validationReport = ['warning' => [], 'error' => [], 'info' => []];
13  protected int $modificationTime = 0;
14  protected int $size = 0;
15  protected array $contextData = [];
16  protected string $veronaModuleType = '';
17  protected string $veronaModuleId;
18  protected int $versionMayor;
19  protected int $versionMinor;
20  protected int $versionPatch;
21  protected string $versionLabel;
22  protected string $veronaVersion;
23
24  public function __construct(
25    string $path = '',
26    string $type = null,
27    string $id = '',
28    string $label = '',
29    string $description = '',
30    bool   $isValid = true,
31    array  $validationReport = [],
32    array  $relations = [],
33    int    $modificationTime = 1,
34    int    $size = 0,
35    array  $contextData = [],
36    string $veronaModuleType = "",
37    string $veronaModuleId = "",
38    int    $versionMayor = 0,
39    int    $versionMinor = 0,
40    int    $versionPatch = 0,
41    string $versionLabel = "",
42    string $veronaVersion = ""
43  ) {
44    $this->path = $path;
45    $this->type = $type;
46    $this->id = $id;
47    $this->label = $label;
48    $this->description = $description;
49    $this->isValid = $isValid;
50    $this->validationReport = $validationReport ?? ['warning' => [], 'error' => [], 'info' => []];
51    $this->relations = $relations;
52    $this->modificationTime = $modificationTime;
53    $this->size = $size;
54    $this->contextData = $contextData;
55    $this->veronaModuleType = $veronaModuleType;
56    $this->veronaModuleId = $veronaModuleId;
57    $this->versionMayor = $versionMayor;
58    $this->versionMinor = $versionMinor;
59    $this->versionPatch = $versionPatch;
60    $this->versionLabel = $versionLabel;
61    $this->veronaVersion = $veronaVersion;
62  }
63
64  public function getType(): string {
65    return $this->type;
66  }
67
68  public function getPath(): string {
69    return $this->path;
70  }
71
72  public function getSize(): int {
73    return $this->size;
74  }
75
76  public function getId(): string {
77    return $this->id;
78  }
79
80  public function setId(string $newId): void {
81    $this->id = $newId;
82  }
83
84  public function getLabel(): string {
85    return $this->label;
86  }
87
88  public function getDescription(): string {
89    return $this->description;
90  }
91
92  public function getRelations(): array {
93    return $this->relations;
94  }
95
96  public function isValid(): bool {
97    return $this->isValid;
98  }
99
100  public function getValidationReport(): array {
101    return $this->validationReport;
102  }
103
104  public function setValidationReport(array $report): void {
105    $this->validationReport = $report;
106  }
107
108  public function getModificationTime(): int {
109    return $this->modificationTime;
110  }
111
112  public function getContextData(): array {
113    return $this->contextData;
114  }
115
116  public function setContextData(array $contextData): void {
117    $this->contextData = $contextData;
118  }
119
120  public function getVeronaModuleType(): string {
121    return $this->veronaModuleType;
122  }
123
124  public function getVeronaModuleId(): string {
125    return $this->veronaModuleId;
126  }
127
128  public function getVersionMayor(): int {
129    return $this->versionMayor;
130  }
131
132  public function getVersionMinor(): int {
133    return $this->versionMinor;
134  }
135
136  public function getVersionPatch(): int {
137    return $this->versionPatch;
138  }
139
140  public function getVersionLabel(): string {
141    return $this->versionLabel;
142  }
143
144  public function getVeronaVersion(): string {
145    return $this->veronaVersion;
146  }
147
148  /**
149   * @param self[] $fileDigestList
150   * @return self[]
151   */
152  public static function removeDeprecatedValues(array $fileDigestList): array {
153    foreach ($fileDigestList as $file) {
154
155      // remove 'unused resource' warning, as this is calculated in FE
156      $report = $file->getValidationReport();
157      if (isset($report['warning'])) {
158        $report['warning'] = array_values(
159          array_filter(
160            $report['warning'],
161            fn(string $warning) => !str_contains($warning, 'is never used')
162          )
163        );
164        $file->setValidationReport($report);
165      }
166
167      // remove totalSize, as this is calculated in FE
168      $contextData = $file->getContextData();
169      if (isset($contextData['totalSize'])) {
170        unset($contextData['totalSize']);
171        $file->setContextData($contextData);
172      }
173    }
174    return $fileDigestList;
175  }
176}