jardisport / classversion
This package provides classversion interfaces for a domain driven design approach
Installs: 75
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Makefile
pkg:composer/jardisport/classversion
Requires
- php: >=8.2
Requires (Dev)
- phpstan/phpstan: ^2.0.4
- squizlabs/php_codesniffer: ^3.11.2
This package is auto-updated.
Last update: 2026-02-25 17:31:02 UTC
README
This package provides classversion interfaces for a domain driven design approach.
Installation
composer require jardisport/classversion
Interfaces
ClassVersionInterface
The main interface for resolving versioned class instances.
interface ClassVersionInterface { /** * @template T * @param class-string<T> $className * @param ?string $version * @return mixed|T */ public function __invoke(string $className, ?string $version = null): mixed; }
ClassVersionConfigInterface
Interface for managing version configuration and fallback chains.
interface ClassVersionConfigInterface { /** * @param string|null $version * @return string|null */ public function version(?string $version = null): ?string; /** * Returns the fallback chain for a given version. * * The chain includes the resolved version itself as the first entry, * followed by any configured fallback versions in order. * The base class (no version) is always the implicit last fallback * and is NOT included in the returned array. * * Example: For version 'v2' with fallbacks ['v2' => ['v1']], * returns ['v2', 'v1']. * * @return array<string> */ public function fallbackChain(?string $version = null): array; }
Usage
Implement these interfaces to create a versioning system for your domain classes, allowing you to manage different versions of class implementations in your DDD architecture.
License
MIT