<?php

declare(strict_types=1);

namespace App\Scolarite\Domain\Model\Competency;

use App\Shared\Domain\Tenant\TenantId;
use DateTimeImmutable;

final class CompetencyFramework
{
    private function __construct(
        public private(set) CompetencyFrameworkId $id,
        public private(set) TenantId $tenantId,
        public private(set) string $name,
        public private(set) bool $isDefault,
        public private(set) DateTimeImmutable $createdAt,
    ) {
    }

    public static function creer(
        TenantId $tenantId,
        string $name,
        bool $isDefault,
        DateTimeImmutable $now,
    ): self {
        return new self(
            id: CompetencyFrameworkId::generate(),
            tenantId: $tenantId,
            name: $name,
            isDefault: $isDefault,
            createdAt: $now,
        );
    }

    /**
     * @internal Pour usage Infrastructure uniquement
     */
    public static function reconstitute(
        CompetencyFrameworkId $id,
        TenantId $tenantId,
        string $name,
        bool $isDefault,
        DateTimeImmutable $createdAt,
    ): self {
        return new self(
            id: $id,
            tenantId: $tenantId,
            name: $name,
            isDefault: $isDefault,
            createdAt: $createdAt,
        );
    }
}
