LibCloud\Compute\ComputeFactory::getProvider PHP Метод

getProvider() публичный статический Метод

public static getProvider ( string $type, string $accessToken ) : LibCloud\Compute\ComputeInterface
$type string provider name
$accessToken string api token
Результат LibCloud\Compute\ComputeInterface
    public static function getProvider($type, $accessToken)
    {
        try {
            $namePart = implode(array_map('ucfirst', explode('_', $type)));
            $className = 'LibCloud\\Compute\\Providers\\' . $namePart . '\\' . $namePart . 'Provider';
            return new $className($accessToken);
        } catch (\Exception $e) {
            throw new \Exception(sprintf("Class for '%s' not found", $type));
        }
    }

Usage Example

 public function setUp()
 {
     $this->provider = ComputeFactory::getProvider('rackspace', 'testuser:some_api_key');
     # parent test case needs this before addMockSubscriber is called
     $this->client = $this->provider->getClient();
     # initial call to getService will perform authentication
     $this->addMockSubscriber($this->getTestFilePath('Auth'));
     $this->addMockSubscriber($this->getTestFilePath('Extensions'));
     $this->provider->getService();
 }
All Usage Examples Of LibCloud\Compute\ComputeFactory::getProvider
ComputeFactory