FloatData.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/FloatData.php
  2. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/FloatData.php
  3. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/FloatData.php

Namespace

Drupal\Core\TypedData\Plugin\DataType

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/FloatData.php

View source
<?php

namespace Drupal\Core\TypedData\Plugin\DataType;

use Drupal\Core\TypedData\PrimitiveBase;
use Drupal\Core\TypedData\Type\FloatInterface;

/**
 * The float data type.
 *
 * The plain value of a float is a regular PHP float. For setting the value
 * any PHP variable that casts to a float may be passed.
 *
 * @DataType(
 *   id = "float",
 *   label = @Translation("Float")
 * )
 */
class FloatData extends PrimitiveBase implements FloatInterface {
    
    /**
     * {@inheritdoc}
     */
    public function getCastedValue() {
        return (double) $this->value;
    }

}

Classes

Title Deprecated Summary
FloatData The float data type.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.