Scalr\Api\Service\User\V1beta0\Controller\FarmRoles::adapter PHP Méthode

adapter() public méthode

Gets a new Instance of the adapter
public adapter ( string | FarmRoleScalingMetric | object $name, string $scope = null, string $version = null ) : ApiEntityAdapter
$name string | Scalr\Model\Entity\FarmRoleScalingMetric | object The name of the adapter or FarmRoleScalingMetric entity or farm role scaling metric data
$scope string optional The scope of the adapter
$version string optional The version of the adapter
Résultat Scalr\Api\DataType\ApiEntityAdapter
    public function adapter($name, $scope = null, $version = null)
    {
        if (is_object($name)) {
            $object = $name;
            if ($object instanceof FarmRoleScalingMetric) {
                $name = ScalingRuleAdapter::$ruleTypeMap[$object->metric->alias];
            } else {
                $name = $this->getBareId($object, 'ruleType');
                if (!$name) {
                    throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, 'Missed property ruleType');
                }
                if (!in_array($name, ScalingRuleAdapter::$ruleTypeMap)) {
                    throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, 'Unexpected ruleType value');
                }
            }
            $name = static::$scalingRuleNamespace . "\\" . $name;
        }
        return parent::adapter($name, $scope, $version);
    }