/**
  * @param string $name
  * @param array  $config
  *
  * @throws InvalidConfigException
  *
  * @return string
  */
 private function className($name, array $config)
 {
     if (isset($config['class']) && isset($config['factory'])) {
         throw InvalidConfigException::fromNameWhenClassAndFactorySpecified($name);
     }
     if (isset($config['class']) && isset($config['service'])) {
         throw InvalidConfigException::fromNameWhenClassAndServiceSpecified($name);
     }
     if (isset($config['factory']) && isset($config['service'])) {
         throw InvalidConfigException::fromNameWhenFactoryAndServiceSpecified($name);
     }
     if (isset($config['service'])) {
         return $config['service'];
     }
     if (isset($config['class'])) {
         return $config['class'];
     }
     if (isset($config['factory'])) {
         return $config['factory'];
     }
     return $name;
 }
 public function testItCanBeCreatedFromNameWhenClassAndFactoryAreSpecified()
 {
     assertSame('Both "class" and "factory" are specified for service "example"; these cannot be used together.', InvalidConfigException::fromNameWhenClassAndFactorySpecified('example')->getMessage());
 }