Search by

stougeiro / structure-contract

stougeiro

Contracts for structured data: immutable structures and schema validation.

Package info

github.com/stougeiro/structure-contract

pkg:composer/stougeiro/structure-contract

Fund package maintenance!

Buymeacoffee

Statistics

Installs: 30

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-12-01 12:38 UTC

This package is auto-updated.

Last update: 2026-12-01 16:23:25 UTC


README

English | Português

PHP PHPStan-Level License

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, returning true/false and 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.