Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Identity
      • Log
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Resource
    • LoadBalancer
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
    • Queues
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

  • AbstractService
  • Catalog
  • CatalogItem
  • Endpoint
  • NovaService
  • ServiceBuilder
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
 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\Exceptions\InvalidArgumentError;
13: 
14: /**
15:  * This object represents the service catalog returned by the Rackspace API. It contains all the services available
16:  * to the end-user, including specific information for each service.
17:  */
18: class Catalog
19: {
20:     /**
21:      * @var array Service items
22:      */
23:     private $items = array();
24: 
25:     /**
26:      * Produces a Catalog from a mixed input.
27:      *
28:      * @param  $config
29:      * @return Catalog
30:      * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
31:      */
32:     public static function factory($config)
33:     {
34:         if (is_array($config)) {
35:             $catalog = new self();
36:             foreach ($config as $item) {
37:                 $catalog->items[] = CatalogItem::factory($item);
38:             }
39:         } elseif ($config instanceof Catalog) {
40:             $catalog = $config;
41:         } else {
42:             throw new InvalidArgumentError(sprintf(
43:                 'Argument for Catalog::factory must be either an array or an '
44:                 . 'instance of %s. You passed in: %s',
45:                 get_class(),
46:                 print_r($config, true)
47:             ));
48:         }
49:         
50:         return $catalog;
51:     }
52: 
53:     /**
54:      * @return array
55:      */
56:     public function getItems()
57:     {
58:         return $this->items;
59:     }
60: }
PHP OpenCloud API API documentation generated by ApiGen 2.8.0