public function testSetGet() { $map = new ObjectMap(); $stack = new \stdClass(); $map->set('MyStack', $stack); $this->assertSame($stack, $map->get('MyStack')); }
/** * Adds a cache to the stack specification * * @param \LayerCache\Cache\CachingLayer|string $cache * @return \LayerCache\StackBuilder */ public function addLayer($cache) { if (is_object($cache)) { if (!$cache instanceof CachingLayer) { throw new \LayerCache\Exception('Cache should implement \\LayerCache\\Cache\\CachingLayer interface!'); } $obj = $cache; } elseif (is_string($cache)) { if (!$this->cacheMap->has($cache)) { throw new \LayerCache\Exception("No named cache found: '{$cache}'"); } $obj = $this->cacheMap->get($cache); } else { throw new Exception('Cache should be an object or a string'); } $this->currentLayer = $this->createLayer($obj); $this->layers[] = $this->currentLayer; return $this; }
/** * Returns a named stack * * Throws an exception if the named stack isn't found. * * @static * @param string $name * @return \LayerCache\Stack */ public static function stack($name) { return self::$stackMap->get($name); }