minvws/icore-php-typearray
最新稳定版本:v1.0.0
Composer 安装命令:
composer require minvws/icore-php-typearray
包简介
Typed Array
README 文档
README
Simple wrapper around property-accessor to fetch elements in a typed way. This package is created because I was fiddling around with a lot of json-arrays that were not typed and phpstan had a big issue with that.
So, instead of having mixed[] $myarray, we can use TypeArray, and fetch elements with:
$arr = new TypeArray(['foo' => 'string', 'bar' => 4 ]);
$arr->getString('[foo]'); // always returns a string
$arr->getString('[notexists]', 'defaultval'); // Returns default val when not found
$arr->getInt('[bar]'); // returns int(4)
$arr->getInt('[foo]'); // Returns InvalidTypeException as this element is a string, not an int
See symfony propertyaccess component for the path syntax used.
统计信息
- 总下载量: 19.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2025-06-27