<?php
declare(strict_types=1);
namespace PpPhp\Core\Platform\Event\Streaming\Replay;
final class StreamPersistenceSnapshot
{
    public function __construct(private readonly array $events = [], private readonly array $replays = [], private readonly array $statistics = [], private readonly string $createdAt = '') {}
    public static function fromArray(array $data): self { return new self((array)($data['events']??[]),(array)($data['replays']??[]),(array)($data['statistics']??[]),(string)($data['createdAt']??'')); }
    public function events(): array { return $this->events; } public function replays(): array { return $this->replays; } public function statistics(): array { return $this->statistics; }
    public function toArray(): array { return ['events'=>$this->events,'replays'=>$this->replays,'statistics'=>$this->statistics,'createdAt'=>$this->createdAt !== '' ? $this->createdAt : date('c')]; }
}
