<?php

namespace Druidfi;

class Envs
{
    const ENV_DEVELOPMENT = 'development';
    const ENV_TESTING = 'testing';
    const ENV_STAGING = 'staging';
    const ENV_PRODUCTION = 'production';
    const ERROR_NOT_VALID = 'Error: env "%s" is not valid! Please use one of the following: %s';

    /**
     * Get error message for invalid env
     *
     * @param $env
     *
     * @return string
     */
    public static function getNotValidErrorMessage($env)
    {
        return sprintf(self::ERROR_NOT_VALID, $env, join(', ', self::getValidEnvs()));
    }

    /**
     * Get list of valid environments
     *
     * @return array Valid environments
     */
    public static function getValidEnvs()
    {
        return [
            self::ENV_DEVELOPMENT,
            self::ENV_TESTING,
            self::ENV_STAGING,
            self::ENV_PRODUCTION,
        ];
    }

    /**
     * Check if given env is valid
     *
     * @param $env
     *
     * @return bool
     */
    public static function isValidEnv($env)
    {
        return in_array($env, self::getValidEnvs());
    }
}
