1: <?php
2: /**
3: * PHP OpenCloud library.
4: *
5: * @copyright 2013 Rackspace Hosting, Inc. See LICENSE for information.
6: * @license https://www.apache.org/licenses/LICENSE-2.0
7: * @author Jamie Hannaford <jamie.hannaford@rackspace.com>
8: */
9:
10: namespace OpenCloud\Common\Service;
11:
12: use OpenCloud\Common\Http\Client;
13: use OpenCloud\Common\Exceptions\ServiceException;
14:
15: /**
16: * This object is a factory for building Service objects.
17: */
18: class ServiceBuilder
19: {
20:
21: /**
22: * Simple factory method for creating services.
23: *
24: * @param Client $client The HTTP client object
25: * @param string $class The class name of the service
26: * @param array $options The options.
27: * @return \OpenCloud\Common\Service\AbstractService
28: * @throws ServiceException
29: */
30: public static function factory(Client $client, $class, array $options = array())
31: {
32: $name = isset($options['name']) ? $options['name'] : null;
33: $region = isset($options['region']) ? $options['region'] : null;
34: $urlType = isset($options['urlType']) ? $options['urlType'] : null;
35:
36: return new $class($client, null, $name, $region, $urlType);
37: }
38:
39: }