wrkflow / php-get-typed-value
从数组 / XML 中获取类型(严格模式)值,并进行基本验证。
v0.8.4
2024-03-27 12:55 UTC
Requires
- php: >=8.1
Requires (Dev)
- ext-simplexml: *
- laravel/framework: ^9.25
- nikic/php-parser: v4.17.1
- orchestra/testbench: ^7.7
- phpstan/phpstan: 1.10.38
- phpstan/phpstan-deprecation-rules: 1.1.4
- phpstan/phpstan-phpunit: 1.3.15
- phpunit/phpunit: 9.6.13
- rector/rector: 0.18.5
- symplify/easy-coding-standard: 12.0.8
Suggests
- wrkflow/larastrict: Improve your Laravel code base with DDD and strict conventions.
README
从数组 / XML 中获取类型(严格模式)值,并进行基本验证。
composer require wrkflow/php-get-typed-value
主要功能
- 🚀 支持使用 安全的点表示法 从 Array (JSON) / XML 中检索具有正确返回类型的值。
- 🏆 使 PHPStan / IDE 满意,因为返回类型是严格的。
- 🤹 验证: 确保所需值是正确的类型(无需额外的循环验证)。
- 🛠 转换器: 确保值是预期的类型。
- ⛑ 将空字符串值转换为 null(可以禁用,请参阅转换器)。
use Wrkflow\GetValue\GetValue; use Wrkflow\GetValue\DataHolders\ArrayData; $data = new GetValue(new ArrayData([ 'address' => [ 'street' => [ 'number' => '13', ], 'name' => '', ] ])); $data->getInt('address.street.number') // Returns: 13 (int) $data->getString('address.street.name') // Returns: null because value does not exists $data->getRequiredString('address.street.name') // Returns: throws MissingValueForKeyException exception
文档
文档托管在 GitHub Pages 上。
评论
我创建了这个项目作为我使命的一部分,旨在创建 work flow
工具/库,使我的(和你的)开发生活更轻松、更有趣。
想要更多工具或想要帮忙?请访问 wrk-flow.com 或 CONTRIBUTE。你可以帮助我改进文档、添加新的测试和功能。你是初级开发者吗?不要害怕,联系我,我将在你的第一次贡献中引导你。