Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
88.89% |
8 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| AuditReportDto | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Packaging\Dto; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Data Transfer Object representing the outcome of a release security and integrity audit. |
| 13 | * |
| 14 | * @package App\Core\Packaging\Dto |
| 15 | */ |
| 16 | final readonly class AuditReportDto |
| 17 | { |
| 18 | /** |
| 19 | * AuditReportDto constructor. |
| 20 | * |
| 21 | * @param bool $passed True if zero violations were encountered. |
| 22 | * @param int $scannedFilesCount Total number of inspected files. |
| 23 | * @param list<string> $violations List of human-readable violation descriptions. |
| 24 | * @param array<string, int> $stats Category breakdown counters. |
| 25 | */ |
| 26 | public function __construct( |
| 27 | public bool $passed, |
| 28 | public int $scannedFilesCount, |
| 29 | public array $violations = [], |
| 30 | public array $stats = [] |
| 31 | ) { |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Serializes audit report into array representation. |
| 36 | * |
| 37 | * @return array{ |
| 38 | * passed: bool, |
| 39 | * scanned_files_count: int, |
| 40 | * violations_count: int, |
| 41 | * violations: list<string>, |
| 42 | * stats: array<string, int> |
| 43 | * } |
| 44 | */ |
| 45 | public function toArray(): array |
| 46 | { |
| 47 | return [ |
| 48 | 'passed' => $this->passed, |
| 49 | 'scanned_files_count' => $this->scannedFilesCount, |
| 50 | 'violations_count' => count($this->violations), |
| 51 | 'violations' => $this->violations, |
| 52 | 'stats' => $this->stats, |
| 53 | ]; |
| 54 | } |
| 55 | } |