Version 1
[yaffs-website] / web / core / lib / Drupal / Core / TypedData / Plugin / DataType / FloatData.php
diff --git a/web/core/lib/Drupal/Core/TypedData/Plugin/DataType/FloatData.php b/web/core/lib/Drupal/Core/TypedData/Plugin/DataType/FloatData.php
new file mode 100644 (file)
index 0000000..4de7e18
--- /dev/null
@@ -0,0 +1,28 @@
+<?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 (float) $this->value;
+  }
+
+}