survos / shape-contracts
Shared value objects for physical shape, dimensions, and measurement units.
Fund package maintenance!
Requires
- php: ^8.5
Requires (Dev)
- phpunit/phpunit: ^13.0
- symplify/easy-coding-standard: ^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.10.19
- 2.10.18
- 2.10.17
- 2.10.16
- 2.10.15
- 2.10.14
- 2.10.13
- 2.10.12
- 2.10.11
- 2.10.10
- 2.10.9
- 2.10.8
- 2.10.7
- 2.10.6
- 2.10.5
- 2.10.4
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.23
- 2.7.22
- 2.7.21
- 2.7.20
- 2.7.19
- 2.7.18
- 2.7.17
- 2.7.16
- 2.7.15
- 2.7.14
- 2.7.13
- 2.7.12
- 2.7.11
- 2.7.10
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.8
- 2.5.7
- 2.5.6
- 2.0.0
This package is auto-updated.
Last update: 2026-08-22 19:57:15 UTC
README
Shared PHP value objects for physical shape and dimensions.
This package is deliberately framework-free. It defines the stable payload that importers, DTO contracts, folio browsing, Symfony bundles, Doctrine storage, parsers, and UI renderers can agree on.
Scope
shape-contracts owns:
- unit identifiers and conversion to millimeters
- immutable single-axis lengths
- immutable physical shape values with nullable axes
- normalized array round-tripping for JSON/DTO payloads
It does not own Symfony services, Doctrine mapping, Twig filters, form types, icons, or
free-text parsing. Those belong in survos/shape-bundle or survos/dimensions-bundle.
Example
use Survos\ShapeContracts\Length; use Survos\ShapeContracts\Shape; use Survos\ShapeContracts\Unit; $shape = new Shape( width: Length::from(18, Unit::CM), height: Length::from(22, Unit::CM), source: '18 x 22 cm', ); $shape->toNormalizedArray(); // [ // 'widthMm' => 180, // 'heightMm' => 220, // 'depthMm' => null, // 'lengthMm' => null, // 'thicknessMm' => null, // 'diameterMm' => null, // 'label' => null, // 'source' => '18 x 22 cm', // ]
Normalized JSON shape
Use camel-case millimeter keys so JSON can be copied directly into DTO data:
{
"widthMm": 180,
"heightMm": 220,
"depthMm": null,
"lengthMm": null,
"thicknessMm": null,
"diameterMm": null,
"label": null,
"source": "18 x 22 cm"
}
The original source/display string should remain in the museum dimensions field when available.
The structured shape is a companion field for consistent storage, querying, and rendering.