<?php
/*
 * Copyright 2026 Alessandro Chiapparini <sprint_planer_web@chiapparini.org>
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the LICENSE file in the project root for the full license text.
 */

declare(strict_types=1);

namespace App\Domain;

final class Sprint
{
    public function __construct(
        public readonly int     $id,
        public readonly string  $name,
        public readonly string  $startDate,         // ISO Y-m-d
        public readonly string  $endDate,           // ISO Y-m-d
        public readonly float   $reserveFraction,   // 0..1
        public readonly bool    $isArchived,
        public readonly string  $createdAt,
        public readonly string  $updatedAt,
    ) {
    }

    public function toAuditSnapshot(): array
    {
        return [
            'id'               => $this->id,
            'name'             => $this->name,
            'start_date'       => $this->startDate,
            'end_date'         => $this->endDate,
            'reserve_fraction' => $this->reserveFraction,
            'is_archived'      => $this->isArchived ? 1 : 0,
            'created_at'       => $this->createdAt,
            'updated_at'       => $this->updatedAt,
        ];
    }
}
