<?php

namespace App\Domain\Clinical;

/**
 * FDI two-digit notation (ISO 3950) — permanent dentition only (MVP).
 * Quadrant 1: upper right 18–11 · Q2: upper left 21–28
 * Quadrant 3: lower left 31–38 · Q4: lower right 41–48
 */
class Fdi
{
    public const UPPER_RIGHT = [18, 17, 16, 15, 14, 13, 12, 11];
    public const UPPER_LEFT = [21, 22, 23, 24, 25, 26, 27, 28];
    public const LOWER_RIGHT = [48, 47, 46, 45, 44, 43, 42, 41];
    public const LOWER_LEFT = [31, 32, 33, 34, 35, 36, 37, 38];

    /** @return int[] all 32 teeth */
    public static function all(): array
    {
        return [
            ...self::UPPER_RIGHT, ...self::UPPER_LEFT,
            ...self::LOWER_RIGHT, ...self::LOWER_LEFT,
        ];
    }

    public static function isValid(int $tooth): bool
    {
        return in_array($tooth, self::all(), true);
    }

    /** Upper arch, screen order (patient's right → left): 18…11 | 21…28 */
    public static function upperArch(): array
    {
        return [...self::UPPER_RIGHT, ...self::UPPER_LEFT];
    }

    /** Lower arch, screen order (mirrors the upper): 48…41 | 31…38 */
    public static function lowerArch(): array
    {
        return [...self::LOWER_RIGHT, ...self::LOWER_LEFT];
    }
}
