DecimalData.php
Same filename in other branches
Namespace
Drupal\Core\TypedData\Plugin\DataTypeFile
-
core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ DecimalData.php
View source
<?php
namespace Drupal\Core\TypedData\Plugin\DataType;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\Attribute\DataType;
use Drupal\Core\TypedData\Type\DecimalInterface;
/**
* The decimal data type.
*
* Decimal type is stored as "decimal" in the relational database. Because PHP
* does not have a primitive type decimal and using float can result in
* unexpected rounding behavior, it is implemented and displayed as string.
*/
class DecimalData extends StringData implements DecimalInterface {
/**
* {@inheritdoc}
*/
public function getCastedValue() {
return $this->getString() ?: '0.0';
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
DecimalData | The decimal data type. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.