Scalr\Api\Service\User\V1beta0\Adapter\ScalingMetricAdapter::metricNameToEntity PHP Method

metricNameToEntity() public static method

Get metrics name used in API to internal representation If metric name exist in nameMapping function will return changed name
public static metricNameToEntity ( string $name ) : string
$name string Metric's name
return string
    public static function metricNameToEntity($name)
    {
        return isset(static::$nameMap[$name]) ? static::$nameMap[$name] : $name;
    }

Usage Example

Esempio n. 1
0
 public function _name($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from Entity\FarmRoleScalingMetric */
             $to->name = ScalingMetricAdapter::metricNameToData($from->metric->name);
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             $this->validateString($from->name, 'Property name contains invalid characters');
             /* @var $metric Entity\ScalingMetric */
             $metric = Entity\ScalingMetric::findOne([['name' => ScalingMetricAdapter::metricNameToEntity($from->name)]]);
             if (empty($metric)) {
                 throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, sprintf('Scaling metric with name %s does not exist', $from->name));
             }
             /* @var $to Entity\FarmRoleScalingMetric */
             $to->metricId = $metric->id;
             $to->metric = $metric;
             break;
         case static::ACT_GET_FILTER_CRITERIA:
             return [[]];
     }
 }
All Usage Examples Of Scalr\Api\Service\User\V1beta0\Adapter\ScalingMetricAdapter::metricNameToEntity