/**
  * combined helper assertion for the test
  *
  * @param  Injector  $injector
  */
 private function assertConstantInjection(Injector $injector)
 {
     $question = $injector->getInstance(Question::class);
     assert($question, equals(new Question(42)));
 }
예제 #2
0
 /**
  * returns the created instance
  *
  * @param   \stubbles\ioc\Injector  $injector
  * @param   string                  $name
  * @return  mixed
  */
 public function getInstance(Injector $injector, $name = null)
 {
     if (null !== $this->provider) {
         return $this->provider->get($name);
     }
     if (null != $this->providerClass) {
         $provider = $injector->getInstance($this->providerClass);
         if (!$provider instanceof InjectionProvider) {
             throw new BindingException('Configured provider class ' . $this->providerClass . ' for constant ' . $this->name . ' is not an instance of stubbles\\ioc\\InjectionProvider.');
         }
         $this->provider = $provider;
         return $this->provider->get($name);
     }
     return $this->value;
 }