<?php

declare(strict_types=1);

namespace App\Framework\Auth;

/**
 * Password Strength Enum
 *
 * Represents the strength assessment of a hashed password
 * based on the algorithm and parameters used.
 */
enum PasswordStrength: string
{
    case VERY_STRONG = 'very_strong';
    case STRONG = 'strong';
    case MODERATE = 'moderate';
    case WEAK = 'weak';
    case UNKNOWN = 'unknown';

    /**
     * Get human-readable label
     */
    public function getLabel(): string
    {
        return match ($this) {
            self::VERY_STRONG => 'Very Strong',
            self::STRONG => 'Strong',
            self::MODERATE => 'Moderate',
            self::WEAK => 'Weak',
            self::UNKNOWN => 'Unknown'
        };
    }

    /**
     * Get security score (0-100)
     */
    public function getScore(): int
    {
        return match ($this) {
            self::VERY_STRONG => 100,
            self::STRONG => 80,
            self::MODERATE => 60,
            self::WEAK => 30,
            self::UNKNOWN => 0
        };
    }

    /**
     * Check if rehash is recommended
     */
    public function shouldRehash(): bool
    {
        return match ($this) {
            self::VERY_STRONG, self::STRONG => false,
            self::MODERATE, self::WEAK, self::UNKNOWN => true
        };
    }

    /**
     * Get color for UI representation
     */
    public function getColor(): string
    {
        return match ($this) {
            self::VERY_STRONG => '#00C853', // Green
            self::STRONG => '#43A047',      // Light Green
            self::MODERATE => '#FFA726',    // Orange
            self::WEAK => '#EF5350',        // Red
            self::UNKNOWN => '#9E9E9E'      // Gray
        };
    }
}
