kero/typesafe-env
最新稳定版本:0.1.3
Composer 安装命令:
composer require kero/typesafe-env
包简介
Wrapper around Laravel's Env to support type safety.
README 文档
README
Install via composer req kero/typesafe-env
Usage
Assuming the following environment variables
API_URL=foo APP_STRING_OR_NULL=null APP_DEBUG=true APP_LOG=false APP_BOOL_OR_NULL=null APP_PI=3 APP_BETTER_PI=3.14
use Kero\TypeSafeEnv\Env; var_dump(Env::getString('API_URL')); // string(3) "foo" var_dump(Env::getNullableString('APP_STRING_OR_NULL')); // NULL var_dump(Env::getBool('APP_DEBUG')); // bool(true) var_dump(Env::getBool('APP_LOG')); // bool(false) var_dump(Env::getNullableBool('APP_BOOL_OR_NULL')); // NULL var_dump(Env::getInt('APP_PI')); // int(3) var_dump(Env::getFloat('APP_PI')); // float(3.14)
❗ Due to Laravel's implementation, both values null and (null) are treated as NULL.
Local Development
Code Style
Currently using plain PSR-12 via Laravel Pint. Apply the code style via
make pint
Tests
Using Pest for testing. Run existing tests via
make test
❗ Tests are relying on the environment variables defined in .env.testing
Type Coverage can also be tested via Pest. Current implementation inside Makefile is buggy ... (TODO: fix so command in Makefile via Docker can be used)
./vendor/bin/pest --type-coverage --min=100
Code Analysis
PHPStan is configured to check ./src/ and ./tests/ via
make analyse
Various
- normalize composer.json file via
ergebnis/composer-normalize
composer normalize
统计信息
- 总下载量: 150
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-28