Scalr\Service\OpenStack\OpenStack::getAvailableServices PHP Method

getAvailableServices() public static method

Gets a list of available services
public static getAvailableServices ( ) : array
return array Returns the list of available services looks like array(serviceName => className)
    public static function getAvailableServices()
    {
        if (!isset(self::$availableServices)) {
            $ns = __NAMESPACE__ . '\\Services';
            $iterator = new GlobIterator(__DIR__ . '/Services/*Service.php', FilesystemIterator::KEY_AS_FILENAME);
            /* @var $item \SplFileInfo */
            foreach ($iterator as $item) {
                $class = $ns . '\\' . substr($iterator->key(), 0, -4);
                if (get_parent_class($class) == $ns . '\\AbstractService') {
                    self::$availableServices[$class::getName()] = $class;
                }
            }
        }
        return self::$availableServices;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @test
  */
 public function testGetAvailableServices()
 {
     $avail = OpenStack::getAvailableServices();
     $this->assertNotEmpty($avail);
     $this->assertInternalType('array', $avail);
     $this->assertArrayHasKey('servers', $avail);
     $this->assertArrayNotHasKey('abstract', $avail);
 }