<?php

declare(strict_types=1);

namespace App\Administration\Application\Query\GetStudentsForParent;

use App\Administration\Domain\Model\StudentGuardian\StudentGuardian;
use App\Administration\Domain\Model\User\User;

/**
 * DTO représentant un élève lié à un parent.
 */
final readonly class StudentForParentDto
{
    public function __construct(
        public string $linkId,
        public string $studentId,
        public string $relationshipType,
        public string $relationshipLabel,
        public string $firstName,
        public string $lastName,
    ) {
    }

    public static function fromDomainWithUser(StudentGuardian $link, User $student): self
    {
        return new self(
            linkId: (string) $link->id,
            studentId: (string) $link->studentId,
            relationshipType: $link->relationshipType->value,
            relationshipLabel: $link->relationshipType->label(),
            firstName: $student->firstName,
            lastName: $student->lastName,
        );
    }
}
