Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
IntegrityVerificationResult
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
2
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
 toArray
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Audit\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Audit Trail Cryptographic Integrity Verification Result.
13 *
14 * Represents the outcome of verifying hash chaining across audit log tables (NIST SP 800-53 AU-9).
15 *
16 * @package App\Core\Audit\Domain\Model
17 */
18final readonly class IntegrityVerificationResult
19{
20    /**
21     * IntegrityVerificationResult constructor.
22     *
23     * @param bool                  $isValid        Whether the entire audit chain is valid and untampered.
24     * @param string                $table          Audit table analyzed.
25     * @param int                   $verifiedCount  Number of records successfully validated.
26     * @param array<int, string>    $violations     List of detected corruption or tampering descriptions.
27     * @param string|null           $latestHash     Cryptographic hash of the latest verified record.
28     */
29    public function __construct(
30        public bool   $isValid,
31        public string $table,
32        public int    $verifiedCount,
33        public array  $violations = [],
34        public ?string $latestHash = null,
35    ) {
36    }
37
38    /**
39     * Converts verification result into an associative array for API presentation.
40     *
41     * @return array<string, mixed> Structured report.
42     */
43    public function toArray(): array
44    {
45        return [
46            'is_valid'       => $this->isValid,
47            'table'          => $this->table,
48            'verified_count' => $this->verifiedCount,
49            'violations'     => $this->violations,
50            'latest_hash'    => $this->latestHash,
51        ];
52    }
53}