<?php

declare(strict_types=1);

namespace App\Enums;

enum PlanInterval: string
{
    case Free = 'free';
    case Monthly = 'monthly';
    case Yearly = 'yearly';
    case Lifetime = 'lifetime';

    public function isRecurring(): bool
    {
        return in_array($this, [self::Monthly, self::Yearly], true);
    }

    public function months(): ?int
    {
        return match ($this) {
            self::Monthly => 1,
            self::Yearly => 12,
            self::Free, self::Lifetime => null,
        };
    }
}
