adachsoft / principal-contact-contracts
Provider-independent PHP contracts and models for storing contact points belonging to principals.
Package info
gitlab.com/a.adach/principal-contact-contracts
pkg:composer/adachsoft/principal-contact-contracts
Requires
- php: ^8.3
- adachsoft/collection: ^3.0
- adachsoft/reference-contracts: ^0.1
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
- phpunit/phpunit: Required to run the repository contract tests from testing/
Provides
None
Conflicts
None
Replaces
None
README
Provider-independent PHP contracts and models for contact points belonging to principals such as users, accounts, or groups. The package keeps contact information separate from authentication and application-specific principal implementations.
Features
- Contact channel, contact point, and principal contact models.
- Repository, service, validation, access-policy, and change-listener interfaces.
- An in-memory repository with optimistic version checks.
- A reusable PHPUnit repository contract test for storage adapters.
This package does not provide a persistent storage adapter or a service implementation.
Requirements
- PHP 8.3 or newer.
- Composer for dependency installation.
Installation
composer require adachsoft/principal-contact-contracts
Composer installs the package's runtime dependencies.
Usage
See the contact points example for creating and querying contact point collections.
Integration
Implement PrincipalContactsRepositoryInterface for your storage backend and use ContactServiceInterface to define application operations. Contact channels are open identifiers: email and phone are provided, and applications may define their own. ContactPointCollection preserves insertion order, prevents duplicate channel/value pairs and multiple primary points for the same channel, and provides channel filtering and primary-point lookup.
An in-memory repository is included for simple use and as a reference implementation. Adapter authors can extend AbstractPrincipalContactsRepositoryContractTest from the AdachSoft\\PrincipalContactContracts\\Testing namespace to check repository behavior.
See the contact points example for a usage sample. See the repository contract test example for adapter integration.