trentonmaki/complex-types
最新稳定版本:1.1.0
Composer 安装命令:
composer require trentonmaki/complex-types
包简介
Adds strongly typed lists and maps
README 文档
README
Complex list and map types for PHP
API
The TypedMap and TypedList API support almost the same interface as an Array (see (ArrayObject)[http://php.net/manual/en/class.arrayobject.php] for an example of this) the differences are in the key values these two types allow and the icompatability with the array_* functions
Usage
Simple subclass TypedList or TypedMap for each kind of list or map you want, then write the isType() or keyType() and valueType() methods.
Example:
class StringList extends TypedList { /** * @param mixed $val * @return bool */ protected function isType($val) { return is_string($val); } }
You can now use StringList as you would a normal array. If someone attempts to put a non string in your list, an exception will be thrown immediately.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-19