<?php

namespace App\Domain\Communication\Enums;

/**
 * Who may read a note (§58).
 *
 * An applicant is not on this list at any level: internal notes are never
 * shown to the person they are about.
 */
enum NoteVisibility: string
{
    case Staff = 'staff';
    case Finance = 'finance';
    case Management = 'management';

    public function label(): string
    {
        return match ($this) {
            self::Staff => 'All permitted staff',
            self::Finance => 'Finance only',
            self::Management => 'Management only',
        };
    }

    /** The permission a reader must hold to see notes at this level. */
    public function requiredPermission(): ?string
    {
        return match ($this) {
            self::Staff => null,
            self::Finance => 'accounting.view',
            self::Management => 'report.financial_view',
        };
    }

    /** @return array<int, string> */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
