Nelmio\Alice\Generator\GenerationContext::getCachedValue PHP Method

getCachedValue() public method

public getCachedValue ( string $key ) : mixed
$key string
return mixed
    public function getCachedValue(string $key)
    {
        if (false === array_key_exists($key, $this->cache)) {
            throw CachedValueNotFound::create($key);
        }
        return $this->cache[$key];
    }

Usage Example

Example #1
0
 public function testCannotRetrieveAnInexistingValueFromCache()
 {
     $context = new GenerationContext();
     try {
         $context->getCachedValue('foo');
         $this->fail('Expected exception to be thrown.');
     } catch (CachedValueNotFound $exception) {
         $this->assertEquals('No value with the key "foo" was found in the cache.', $exception->getMessage());
         $this->assertEquals(0, $exception->getCode());
         $this->assertNull($exception->getPrevious());
     }
 }
All Usage Examples Of Nelmio\Alice\Generator\GenerationContext::getCachedValue