ucarsolutions / entities
A collection of commonly used entities
dev-main
2025-05-12 10:03 UTC
Requires
- php: >8.1
- doganoo/php-algorithms: ^2.1
Requires (Dev)
- phpunit/phpunit: ^12.1
This package is auto-updated.
Last update: 2025-05-12 10:04:05 UTC
README
Reusable, immutable PHP entities for consistent data modeling across projects.
This package provides a collection of simple, readonly PHP entities (Value Objects, Enums, and Interfaces) shared across multiple UcarSolutions projects. It helps enforce structure, improve consistency, and eliminate duplication in business logic and data transport.
๐ฆ Installation
Install via Composer:
composer require ucarsolutions/entities
PHP 8.1+ is required (due to usage of readonly classes and Enums).
๐ง Features
- Immutable readonly value objects (e.g., User, Organization, Role)
- Typed enums for controlled values (e.g., Status, Subscription, Verb)
- Interfaces for enforcing structure
- Designed to be framework-agnostic
๐ Example Usage
use UcarSolutions\Entities\User\User; use UcarSolutions\Entities\User\Status; use UcarSolutions\Entities\User\Subscription; use DateTimeImmutable; $user = new User( id: 'user-123', name: 'Max Mustermann', email: 'jane@example.com', password: 'hashed-password', token: 'token-value', status: Status::ENABLED, subscription: Subscription::PAID, createTs: new DateTimeImmutable() );
๐งช Running Tests
This package uses PHPUnit:
composer install vendor/bin/phpunit
๐ค Contributing
We welcome contributions! Please make sure to:
- Follow PSR coding standards
- Add unit tests for new or changed functionality
- Submit your pull request against the main branch