public function create($service)
{
// if it's an object, we just want to return it
if (is_object($service)) {
return $service;
}
// if it's not a string, we don't know how to handle this type
if (!is_string($service)) {
throw new RetrofitException(sprintf('Could not create client. Expected object or string, got "%s"', gettype($service)));
}
// get the class as a string
// if $service is already a class, use that, otherwise,
if (class_exists($service)) {
$class = $service;
} elseif (interface_exists($service)) {
$class = Retrofit::NAMESPACE_PREFIX . '\\' . $service;
} else {
throw new RetrofitException(sprintf('Could not create client. "%s" should be a class or interface.', $service));
}
return new $class($this->baseUrl, $this->httpClient, $this->eventDispatcher, $this->serializerAdapter, $this->deserializerAdapter);
}