Index: docroot/modules/contrib/physical/src/Dimensions.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- docroot/modules/contrib/physical/src/Dimensions.php	(revision )
+++ docroot/modules/contrib/physical/src/Dimensions.php	(revision )
@@ -0,0 +1,132 @@
+<?php
+
+namespace Drupal\physical;
+
+
+/**
+ * Provides a base class for dimensions value objects.
+ */
+class Dimensions {
+
+   /**
+    * The measurement type.
+    *
+    * @var string
+    */
+   protected $type = MeasurementType::LENGTH;
+
+   /**
+   * The Length.
+   *
+   * @var string
+   */
+  protected $length;
+
+  /**
+   * The Width.
+   *
+   * @var string
+   */
+  protected $width;
+
+  /**
+   * The Height.
+   *
+   * @var string
+   */
+  protected $height;
+
+  /**
+   * The unit.
+   *
+   * @var string
+   */
+  protected $unit;
+
+  /**
+   * Constructs a new Dimensions object.
+   *
+   * @param string $length
+   *   The Length.
+   * @param string $width
+   *   The Width.
+   * @param string $height
+   *   The Height.
+   * @param string $unit
+   *   The unit.
+   */
+  public function __construct($length, $width, $height, $unit) {
+    Calculator::assertNumberFormat($length);
+    Calculator::assertNumberFormat($width);
+    Calculator::assertNumberFormat($height);
+    /** @var \Drupal\physical\UnitInterface $units_class */
+    $units_class = MeasurementType::getUnitClass($this->type);
+    $units_class::assertExists($unit);
+
+    $this->length = (string) $length;
+    $this->width = (string) $width;
+    $this->height = (string) $height;
+    $this->unit = $unit;
+  }
+
+  /**
+   * Gets the length.
+   *
+   * @return string
+   *   The length.
+   */
+  public function getLength() {
+    return $this->length;
+  }
+
+  /**
+   * Gets the width.
+   *
+   * @return string
+   *   The width.
+   */
+  public function getWidth() {
+    return $this->width;
+  }
+
+  /**
+   * Gets the height.
+   *
+   * @return string
+   *   The height.
+   */
+  public function getHeight() {
+    return $this->height;
+  }
+
+  /**
+   * Gets the unit.
+   *
+   * @return string
+   *   The unit.
+   */
+  public function getUnit() {
+    return $this->unit;
+  }
+
+  /**
+   * Gets the string representation of the measurement.
+   *
+   * @return string
+   *   The string representation of the measurement.
+   */
+  public function __toString() {
+    return Calculator::trim($this->length) . ' ' . $this->unit . " X " . Calculator::trim($this->width) . ' ' . $this->unit . " X " . Calculator::trim($this->height) . ' ' . $this->unit;
+  }
+
+  /**
+   * Gets the array representation of the measurement.
+   *
+   * @return array
+   *   The array representation of the measurement.
+   */
+  public function toArray() {
+    return ['length' => $this->length, 'width' => $this->width, 'height' => $this->height, 'unit' => $this->unit];
+  }
+
+}
Index: docroot/modules/contrib/physical/src/Plugin/Field/FieldType/DimensionsItem.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- docroot/modules/contrib/physical/src/Plugin/Field/FieldType/DimensionsItem.php	(revision dcda5f9cb6bd5a65e7a93336e0dbccd5ee20d322)
+++ docroot/modules/contrib/physical/src/Plugin/Field/FieldType/DimensionsItem.php	(revision )
@@ -5,6 +5,7 @@
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\TypedData\DataDefinition;
+use Drupal\physical\Dimensions;
 use Drupal\physical\Length;
 
 /**
@@ -121,9 +122,26 @@
    */
   protected function checkEmpty($value) {
     return is_null($value) || $value === '';
+  }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function setValue($values, $notify = TRUE) {
+        // Allow callers to pass a Measurement value object as the field item value.
+        if ($values instanceof Dimensions) {
+            $dimensions = $values;
+            $values = [
+                'length' => $dimensions->getLength(),
+                'width' => $dimensions->getWidth(),
+                'height' => $dimensions->getHeight(),
+                'unit' => $dimensions->getUnit(),
+            ];
+        }
+        parent::setValue($values, $notify);
-  }
+    }
 
-  /**
+    /**
    * Gets the length as a value object.
    *
    * @return \Drupal\physical\Length
