Scalr\Api\Service\User\V1beta0\Controller\CloudCredentials::adapter PHP Метод

adapter() публичный Метод

Gets a new Instance of the adapter
public adapter ( string | CloudCredentials | object $name, string $scope = null, string $version = null, array $transform = null ) : ApiEntityAdapter
$name string | CloudCredentials | object The name of the adapter, or CloudCredentials entity, or cloud credentials data
$scope string optional The scope of the adapter
$version string optional The version of the adapter
$transform array optional The transformation rules for the type of the cloud credentials
Результат Scalr\Api\DataType\ApiEntityAdapter Returns the instance of cloud credentials adapter
    public function adapter($name, $scope = null, $version = null, array $transform = null)
    {
        if (is_object($name)) {
            $property = $name instanceof $this->entityClass ? static::$entityDescriminator : static::$objectDiscriminator;
            $value = empty($transform) ? $name->{$property} : $transform[$name->{$property}];
            switch (true) {
                case PlatformFactory::isOpenstack($value, true):
                    $value = SERVER_PLATFORMS::OPENSTACK;
                    break;
                case PlatformFactory::isCloudstack($value):
                    $value = SERVER_PLATFORMS::CLOUDSTACK;
                    break;
                case PlatformFactory::isRackspace($value):
                    $value = self::PLATFORM_CLASS_RACKSPACE;
                    break;
            }
            if (!isset(static::$inheritanceMap[$value])) {
                throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Unknown cloud '{$value}'");
            }
            $class = empty(static::$inheritanceMap) ? $value : static::$inheritanceMap[$value];
            $name = empty(static::$inheritedNamespace) ? $class : static::$inheritedNamespace . "\\{$class}";
        }
        return parent::adapter($name, $scope, $version);
    }