/** * Simple factory method for creating services. * * @param Client $client The HTTP client object * @param string $class The class name of the service * @param array $options The options. * @return \OpenCloud\Common\Service\ServiceInterface * @throws ServiceException */ public static function factory(ClientInterface $client, $class, array $options = array()) { $name = isset($options['name']) ? $options['name'] : null; $urlType = isset($options['urlType']) ? $options['urlType'] : null; if (isset($options['region'])) { $region = $options['region']; } elseif ($client->getUser() && ($defaultRegion = $client->getUser()->getDefaultRegion())) { $region = $defaultRegion; } else { $region = null; } return new $class($client, null, $name, $region, $urlType); }