<?php

namespace App\Enums;

/**
 * The kind of content a QR code encodes.
 */
enum QrCodeType: string
{
    case Url = 'url';
    case Text = 'text';
    case VCard = 'vcard';
    case Wifi = 'wifi';
    case Email = 'email';
    case Phone = 'phone';
    case Sms = 'sms';

    /**
     * Get the display label for the type.
     */
    public function label(): string
    {
        return match ($this) {
            self::Url => 'URL',
            self::Text => 'Text',
            self::VCard => 'vCard',
            self::Wifi => 'WiFi',
            self::Email => 'Email',
            self::Phone => 'Phone',
            self::Sms => 'SMS',
        };
    }

    /**
     * Determine whether this type can be a "dynamic" QR code that redirects
     * through `/q/{short_code}` and is measurable via scan analytics.
     *
     * Only `Url` codes can be dynamic: every other type encodes its payload
     * (vCard fields, WiFi credentials, etc.) directly into the QR image, so
     * there is nothing on our server to redirect to or measure.
     */
    public function supportsDynamic(): bool
    {
        return $this === self::Url;
    }
}
