diff --git a/src/Environment.php b/src/Environment.php index 8cf11c1..f538f2e 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -4,9 +4,6 @@ namespace Rancoud\Environment; -/** - * Class Environment. - */ class Environment { public const int GETENV = 0x01; @@ -47,15 +44,10 @@ class Environment protected string $endline = \PHP_EOL; - /** - * Environment constructor. - * - * @param array|string $folders - */ - public function __construct($folders, string $filename = '.env') + public function __construct(array|string $folders, string $filename = '.env') { if (!\is_array($folders)) { - $folders = [(string) $folders]; + $folders = [$folders]; } $this->folders = $folders; @@ -228,8 +220,7 @@ protected function extractText(string $line): void } } - /** @return bool|float|int|string|null */ - protected function convertType(string $value): mixed + protected function convertType(string $value): bool|float|int|string|null { $val = \mb_strtolower($value); if ($val === 'true') { @@ -269,7 +260,7 @@ protected function replaceVariables(string $value): string return $value; } - protected function set(string $key, $value): void + protected function set(string $key, mixed $value): void { $this->env[$key] = $value; } @@ -287,11 +278,10 @@ protected function saveInCache(): void } /** - * @param mixed|null $default * @throws EnvironmentException * @return mixed|null */ - public function get(string $key, $default = null) + public function get(string $key, mixed $default = null): mixed { $this->autoload(); @@ -310,17 +300,13 @@ public function getAll(): array return $this->env; } - /** - * @param array|string $keys - * - * @throws EnvironmentException - */ - public function exists($keys): bool + /** @throws EnvironmentException */ + public function exists(array|string $keys): bool { $this->autoload(); if (!\is_array($keys)) { - $keys = [(string) $keys]; + $keys = [$keys]; } foreach ($keys as $key) { diff --git a/src/EnvironmentException.php b/src/EnvironmentException.php index 8081131..7a1cd75 100644 --- a/src/EnvironmentException.php +++ b/src/EnvironmentException.php @@ -4,7 +4,4 @@ namespace Rancoud\Environment; -/** - * Class EnvironmentException. - */ class EnvironmentException extends \Exception {} diff --git a/tests/EnvironmentTest.php b/tests/EnvironmentTest.php index 56dec43..e9e30bc 100644 --- a/tests/EnvironmentTest.php +++ b/tests/EnvironmentTest.php @@ -8,11 +8,7 @@ use Rancoud\Environment\Environment; use Rancoud\Environment\EnvironmentException; -/** - * Class EnvironmentTest. - * - * @internal - */ +/** @internal */ class EnvironmentTest extends TestCase { protected array $fileEnvContent = [ @@ -64,10 +60,8 @@ class EnvironmentTest extends TestCase protected function getProtectedValue(Environment $env, string $name) { $reflexion = new \ReflectionClass(Environment::class); - $prop = $reflexion->getProperty($name); - $prop->setAccessible(true); - return $prop->getValue($env); + return $reflexion->getProperty($name)->getValue($env); } public function testBitmasking(): void