ucarsolutions/entities

A collection of commonly used entities

dev-main 2025-05-12 10:03 UTC

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:

  1. Follow PSR coding standards
  2. Add unit tests for new or changed functionality
  3. Submit your pull request against the main branch