package helpers

import (
	"os"
	"strconv"
)

func EnvInt(name string, fallback int, minimum int) int {
	rawValue := os.Getenv(name)
	if rawValue == "" {
		return fallback
	}

	value, err := strconv.Atoi(rawValue)
	if err != nil || value < minimum {
		return fallback
	}

	return value
}
