lookup() public method

Looks up a key in the registry, with an optional closure that that will be executed and the result stored if the key doesn't exist (and there is no trigger).
public lookup ( $key, $closure = null ) : Object
return Object
Example #1
0
 public function testTriggerTrumpsClosureOnMiss()
 {
     $registry = new Registry();
     $registry->trigger('my_key', function ($r) {
         $r->register('my_key', (object) array('source' => 'trigger'));
     });
     $result = $registry->lookup('my_key', function () {
         return (object) array('source' => 'closure');
     });
     $this->assertEquals($result->source, 'trigger');
 }