示例#1
0
 /**
  * {@inheritDoc}
  */
 public function get($name)
 {
     if (!$this->services->has($name)) {
         throw new InvalidArgumentException(sprintf('Service "%s" is not defined.', $name));
     }
     /** @var Closure $service */
     $service = $this->services->get($name);
     if ($this->services->isLocked($name) || !method_exists($this->services->get($name), '__invoke')) {
         return $service;
     }
     if ($this->factories->contains($service)) {
         return $service($this);
     }
     $this->services->set($name, $service($this));
     $this->services->lock($name);
     return $this->services->get($name);
 }
示例#2
0
 /**
  * @expectedException \Phimple\Exception\ItemNotFoundException
  * @expectedExceptionMessage Item "item" could not be found.
  */
 public function testIsLockedAfterRemove()
 {
     $lockbox = new LockBox();
     $lockbox->set('item', 'value');
     $lockbox->lock('item');
     $lockbox->remove('item');
     $lockbox->isLocked('item');
 }