<?php

namespace ProudNerds\Helpers;

enum Env: string
{
    case DEVELOPMENT = 'development';
    case TESTING = 'testing';
    case ACCEPTANCE = 'acceptance';
    case PRODUCTION = 'production';

    public static function getAsString(): string
    {
        return $_ENV['WP_ENV'] ?? Env::DEVELOPMENT->value;
    }

    public static function get(): Env
    {
        return match (Env::getAsString()) {
            Env::DEVELOPMENT->value => Env::DEVELOPMENT,
            Env::TESTING->value => Env::TESTING,
            Env::ACCEPTANCE->value => Env::ACCEPTANCE,
            Env::PRODUCTION->value => Env::PRODUCTION,
        };
    }

    public static function is(Env $environment): bool
    {
        return Env::get() === $environment;
    }

    public static function isNot(Env $environment): bool
    {
        return !Env::is($environment);
    }
}
