From 8d67b4078a0429bb92d12c5bd4654654def471c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radovan=20Kepa=CC=81k?= Date: Thu, 12 Aug 2021 17:53:48 +0200 Subject: [PATCH] Update Environment.php --- src/Environment.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Environment.php b/src/Environment.php index 460aa12..da82371 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -8,7 +8,9 @@ class Environment { public const STRING = 'string'; public const BOOL = 'bool'; + public const BOOLEAN = 'boolean'; public const INT = 'int'; + public const INTEGER = 'integer'; public const FLOAT = 'float'; public function __construct( @@ -25,8 +27,8 @@ public static function bool(string $name, bool $default = false): bool private static function castIt(?string $value, string $cast): null|string|bool|int|float { return ($value !== null) ? match ($cast) { - self::BOOL => !($value === 'false' || !$value), - self::INT => (int)$value, + self::BOOL, self::BOOLEAN => !($value === 'false' || !$value), + self::INT, self::INTEGER => (int)$value, self::FLOAT => (float)$value, default => $value, } : null; @@ -60,6 +62,6 @@ public function __toString(): string public function get(string $cast = self::STRING): string|bool|int|float { - return self::castIt(self::env($this->name) ?? $this->default, $cast) ?? ''; + return self::castIt(self::env($this->name) ?? $this->default, strtolower($cast)) ?? ''; } } \ No newline at end of file