stougeiro / structure-contract
Contracts for structured data: immutable structures and schema validation.
Fund package maintenance!
v0.1.0
2026-12-01 12:38 UTC
Requires
- php: ^8.3
Requires (Dev)
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 16:23:25 UTC
README
Structure Contract
Contracts for structured data. This package defines only the boundaries shared by immutable structures and schema validation; it carries no runtime behavior.
✨ Contracts
ImmutableInterface— an immutable structure: creation from an array, safe nested access, presence checks (has()), array access, iteration and conversion back to a plain array.SchemaInterface— validates a payload against an expected structure, returningtrue/falseand an optional error message.StructureExceptionInterface— the single exception marker every implementation uses, so failures are catchable through one type.
📦 Installation
composer require stougeiro/structure-contract
🔧 Implementations
stougeiro/structure-immutable— immutable data structures.stougeiro/structure-schema— structural gate / schema validation.
🧠 Why?
Immutability and validation are complementary halves of structured data: one freezes the structure, the other checks that the structure is the expected one. Sharing a contract keeps both interoperable without coupling their releases.
🤝 Contributions
Contributions are welcome. Feel free to open issues or submit pull requests.