PHP code example of stratadox / identity-map

1. Go to this page and download the library: Download stratadox/identity-map library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stratadox / identity-map example snippets


$map = IdentityMap::with([
    'id1' => $object1,
    'id2' => $object2,
]);

$map = IdentityMap::startEmpty();

$map = $map->add('id3', $object3);

$map = $map->remove(Foo::class, 'id3');

$map = $map->removeThe($object);

if ($map->has(Foo::class, '1')) { ...

$object = $map->get(Foo::class, '1');

if ($map->hasThe($object)) { ...

$id = $map->idOf($object);

$map = Whitelist::forThe(IdentityMap::startEmpty(), MyEntity::class);

$map = Whitelist::forThe(IdentityMap::startEmpty(), Foo::class, Bar::class);

$map = Whitelist::the(Foo::class, Bar::class);