harp-orm/identity-map
Composer 安装命令:
composer require harp-orm/identity-map
包简介
Allow only identical objects
README 文档
README
This package allows having "canonical objects".
Usage
Assuming "new Item(1)" will have id of "1":
$map = new IdentityMap(function ($item) { return $item->getId(); }); $item1 = new Item(1); $item2 = new Item(1); $item3 = new Item(2); echo $map->get($item1); // Will return item1 echo $map->get($item2); // Will return item1 echo $map->get($item3); // Will return item3
That way you can make sure items with the same key are the same physical objects
The closure argument that use pass to the identity map, needs to return the "unique key" for each product.
License
Copyright (c) 2014-2015, Clippings Ltd. Developed by Ivan Kerin as part of Clippings.com
Under BSD-3-Clause license, read LICENSE file.
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-09-03