Skip to content

Commit a8736bf

Browse files
chore: add optional cast support to env helper and document it
1 parent b0bbaed commit a8736bf

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All significant changes to this project will be documented in this file.
44

5+
## [1.4.1] - 2026-01-03
6+
7+
### Changed
8+
9+
- Added optional `$cast parameter to global `env()`helper to enable typed casting via`Env::getCast()`.
10+
511
## [1.4.0] - 2026-01-02
612

713
### Changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ require __DIR__ . '/vendor/autoload.php';
4646

4747
// ENV
4848
$env = env('APP_ENV', 'production');
49+
$debug = env('APP_DEBUG', false, true);
4950

5051
// Config
5152
config(['app.name' => 'Codemonster']);

src/helpers/env.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use Codemonster\Env\Env;
44

55
if (!function_exists('env')) {
6-
function env(string $key, mixed $default = null): mixed
6+
function env(string $key, mixed $default = null, bool $cast = false): mixed
77
{
8-
return Env::get($key, $default);
8+
return Env::getCast($key, $default, $cast);
99
}
1010
}

0 commit comments

Comments
 (0)