2017 © Pedro Peláez
 

library identity-map

Allow only identical objects

image

harp-orm/identity-map

Allow only identical objects

  • Wednesday, September 9, 2015
  • by hkdobrev
  • Repository
  • 2 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Identity Map

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version, (*1)

This package allows having "canonical objects"., (*2)

Usage

Assuming "new Item(1)" will have id of "1":, (*3)

$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, (*4)


The closure argument that use pass to the identity map, needs to return the "unique key" for each product., (*5)

License

Copyright (c) 2014-2015, Clippings Ltd. Developed by Ivan Kerin as part of Clippings.com, (*6)

Under BSD-3-Clause license, read LICENSE file., (*7)

The Versions

09/09 2015

dev-master

9999999-dev

Allow only identical objects

  Sources   Download

BSD-3-Clause

09/09 2015

0.1.1

0.1.1.0

Allow only identical objects

  Sources   Download

BSD-3-Clause

03/09 2014

0.1

0.1.0.0

Allow only identical objects

  Sources   Download

BSD-3-Clause