/** * Resolves a dependency. * * If a cache is set, the cache is queried before calling <code>getResolve</code>. * * @param string $dependency the name of the dependency * @return mixed the resolved object */ public function resolve($dependency) { if ($this->cache !== null) { $resolved = $this->cache->fetch($dependency); if ($resolved !== null) { return unserialize(base64_decode($resolved)); } } $resolved = $this->getResolve($dependency); if ($this->cache !== null) { $this->cache->store($dependency, base64_encode(serialize($resolved))); } return $resolved; }
/** * Tests fetching a cached value. * * @covers empire\framework\storage\cache\Cache::fetch */ public function testFetch() { $this->cache->store('hello', 'world'); $this->assertSame('world', $this->cache->fetch('hello')); }