<?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 Task
{
    public function __construct(
        public readonly int    $id,
        public readonly int    $sprintId,
        public readonly string $title,
        public readonly ?int   $ownerWorkerId,
        public readonly int    $priority,         // 1 or 2
        public readonly int    $sortOrder,
        public readonly string $createdAt,
        public readonly string $updatedAt,
        public readonly string $description = '',
        public readonly string $url          = '',
        public readonly ?int   $linkedTaskId = null,
    ) {
    }

    public function toAuditSnapshot(): array
    {
        return [
            'id'              => $this->id,
            'sprint_id'       => $this->sprintId,
            'title'           => $this->title,
            'owner_worker_id' => $this->ownerWorkerId,
            'priority'        => $this->priority,
            'sort_order'      => $this->sortOrder,
            'created_at'      => $this->createdAt,
            'updated_at'      => $this->updatedAt,
            'description'     => $this->description,
            'url'             => $this->url,
            'linked_task_id'  => $this->linkedTaskId,
        ];
    }
}
