*/ private array $byKind; /** * Newest-first projected row slice produced by * {@see ListAuditEventsUseCase::projectRow()}. * * Each entry is the §12.4 envelope row carrying * `audit_event_type` / `audit_kind` / `actor` / `target` / * `action` / `result` / `safe_summary` / * `changed_fields_summary` / `request_id` / * `correlation_id` / `job_id` / `created_at` slots. * * @var list> */ private array $recent; /** * Effective recent-limit value the use case applied after * clamping, echoed back so REST consumers can render * `"showing the most recent N entries"` text without * re-deriving the bound. */ private int $recentLimit; /** * Total `affilun_audit_events` row count across every kind. * * Computed by the use case as the sum of `$byKind`'s values * so the summary card can surface a headline * `"N audit events recorded"` without an additional * {@see \Affilun\Infrastructure\Persistence\AuditEventRepository::count()} * round-trip. */ private int $total; /** * Construct the result with explicit values for every axis. * * @param array $byKind Per-kind row count map. * @param list> $recent Projected row slice. * @param int $recentLimit Effective recent-limit. * @param int $total Total row count across every kind. */ public function __construct( array $byKind, array $recent, int $recentLimit, int $total ) { $this->byKind = $byKind; $this->recent = array_values( $recent ); $this->recentLimit = $recentLimit; $this->total = $total; } /** * Per-`audit_kind` row count map, default-filled against * {@see \Affilun\Infrastructure\Persistence\AuditEventListQuery::VALID_AUDIT_KINDS}. * * @return array */ public function byKind(): array { return $this->byKind; } /** * Newest-first projected row slice. * * @return list> */ public function recent(): array { return $this->recent; } /** * Effective recent-limit value applied after clamping. */ public function recentLimit(): int { return $this->recentLimit; } /** * Total `affilun_audit_events` row count across every kind. */ public function total(): int { return $this->total; } /** * Render the §12.5 success envelope `data` shape: * * `array( * 'by_kind' => array, * 'recent' => list>, * 'recent_limit' => int, * 'total' => int, * )` * * @return array{ * by_kind: array, * recent: list>, * recent_limit: int, * total: int, * } */ public function toArray(): array { return array( 'by_kind' => $this->byKind, 'recent' => $this->recent, 'recent_limit' => $this->recentLimit, 'total' => $this->total, ); } }