Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Common Value Objects Laravel Package

apie/common-value-objects

Common value objects for the Apie ecosystem: ready-to-use PHP enums (e.g., Gender) and identifier base classes (e.g., UUID v4) for entities, fields, or composite value objects. Designed to be extended and used as examples in your own domain.

View on GitHub
Deep Wiki
Context7

Latest Stable Version Total Downloads Latest Unstable Version License PHP Composer

PHP Composer

This package is part of the Apie library. The code is maintained in a monorepo, so PR's need to be sent to the monorepo

Documentation

A set of common value object classes that can be used right away or can be used as examples how to make common value objects.

Enums

enums are just PHP enums with common values. They are fully supported by Apie.

Enums Description
Gender Indicate male or female

Identifiers

Identifiers are used by Apie entities to tell the id of an entity. To use these as identifiers for your entity, you need to extend one of these and implement the IdentifierInterface. Otherwise you can also use them as property fields on an entity or a composite value object.

Example:

<?php
use Apie\Core\Identifiers\UuidV4;
use Apie\Core\Identifiers\IdentifierInterface;

class UserIdentifier extends UuidV4 implements IdentifierInterface
{
    public static function getReferenceFor(): ReflectionClass
    {
        return new ReflectionClass(User::class);
    }
}
<?php
use Apie\Core\Entities\EntityInterface;

class User implements EntityInterface
{
    private UserIdentifier $id;

    public function __construct()
    {
        $this->id = UserIdentifier::createRandom();
    }

    public function getIdentifier(): UserIdentifier
    {
        return $this->id;
    }
}
Class Description
KebabCaseSlug Slug in the shape of "example-slug"
PascalCaseSlug Slug in the shape of "example_slug"
Slug Slug in the shape of "exampleslug"
Uuid Any string in the shape of an uuid
UuidV1 Uuid in version 1 format
UuidV2 Uuid in version 2 format
UuidV3 Uuid in version 3 format
UuidV4 Uuid in version 4 format
UuidV5 Uuid in version 5 format
UuidV6 Uuid in version 6 format

Name value objects

Contains value objects related to names. They are very tolerant what is written in them and support unicode characters to avoid wrong assumptions about what is a valid first and last name.

Class Description
FirstName First name
LastName Last name

Range value objects

Ranges often have a restriction related that for example the start should always be lower than the end. They are often a composite of 2 values.

Class Description
DateTimeRange A range between dates. The first date should always be lower than the last date

Text value objects

At first these value objects seem redundant as you wonder why you should not just use string, but the problem with using string is that it has no restriction on the length of a text. The value object will also mean you can tell an application it requires a non-empty text for example.

Class Description
SmallDatabaseText A string that fits into a database varchar field (255 characters). The text will be trimmed and can be empty.
StrongPasswordField A string used for passwords that are considered strong passwords.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast