PHPackages                             funeralzone/valueobject-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. funeralzone/valueobject-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

funeralzone/valueobject-generator
=================================

A generator for immutable Value Objects

3.1.1(6y ago)214.0k2PHPPHP &gt;=7.1.0CI failing

Since Jun 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/funeralzone/valueobject-generator)[ Packagist](https://packagist.org/packages/funeralzone/valueobject-generator)[ RSS](/packages/funeralzone-valueobject-generator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (7)Versions (28)Used By (0)

Value object generator
======================

[](#value-object-generator)

Upgrade notes for V0 to V1
--------------------------

[](#upgrade-notes-for-v0-to-v1)

### Everything is a model

[](#everything-is-a-model)

There is no longer a strong bias toward Event Sourcing so the concept of *events*, *commands*, *queries* and *deltas* has been removed and the onus of implementing these placed on the types/template library.

The practical upshots of this change are as follows:

#### *events*, *commands*, *queries* and *deltas*

[](#events-commands-queries-and-deltas)

- Top level items for *events*, *commands*, *queries* and *deltas* have been removed; every model lives under the *model* top-level item
- When creating *events*, *commands*, *queries* and *deltas* there is no *deltas* property; use must define *children* models that happen to implement delta behaviour
- *events*, *commands*, *queries* and *deltas* are now dedicated **types** - *Event*, *Command*, *Query* and *Delta* respectively

#### Seeding models from Prooph meta data

[](#seeding-models-from-prooph-meta-data)

The *Event*, *Command*, *Query* and *Delta* **types** include a *fromMetaDataKey* property that allows you to define a Prooph metadata key to seed from

```
- name: ExampleEvent
  type: Event
  children:
    - name: ExampleEventAggregateId
      type: Uuid
      propertyName: id
      fromMetaDataKey: _aggregateId
```

#### Deltas seeded with the root payload

[](#deltas-seeded-with-the-root-payload)

Deltas can no longer automatically receive the root payload of a *command*/*event*.

In V0 you could optionally supply a *useRootData* flag in the definition which meant the *delta* received the entire payload of the *event* or *command* rather than just its specific property. This is no longer possible.

In order to re-create this behaviour you can bundle up the necessary properties within the Prooph resolver and add a fabricated array property to the *command*/*events* payload.

#### Sets no longer accept child models

[](#sets-no-longer-accept-child-models)

In V0 sets would require a single child model which inferred the type of contents the *Set* would accept. This is no longer possible.

In V1 you must explicitly define the type of model a *Set* can contain by setting the *modelToEnforce* property. This property must reference a valid model.

```
- name: OrganisationalUnitId
  type: Uuid

- name: OrganisationalUnitIds
  type: Set
  modelToEnforce: OrganisationalUnitId
```

#### Decorators

[](#decorators)

Decorators have had a overhaul:

- you can now have multiple decorators per model
- you do not define their target, i.e. the *nullDecorator*, *nonNUllDecorator* and *nullableDecerator* properties are defunct
- they are hook based, allowing decorators to be tied into different actions within a model

Available hooks:

- **constructor** - executes during the constructor of a model and receives all arguments used to instantiate the object

```
decorators:
- path: Funeralzone\FAS\Common\ValueObjects\Decorators\DecoratorOne
  hooks:
  - type: constructor
    method: methodToCallOnConstructOne

- path: Funeralzone\FAS\Common\ValueObjects\Decorators\DecoratorTwo
  hooks:
  - type: constructor
    method: methodToCallOnConstructTwo
```

Example definition
------------------

[](#example-definition)

```
namespace: ValueObjects

model:

  # External models
  # ==========================

  - name: EntityId
    type: String
    namespace: Funeralzone\FAS\DomainEntities
    testing:
      fromNative: "'1'"
      constructor: "'1'"

  # Data models
  # ==========================
  - name: TenantId
    type: Uuid

  - name: BereavedId
    type: Uuid

  - name: ContactId
    type: Uuid

  - name: DirectoryListingId
    type: Uuid

  - name: MediaId
    type: String
    decorators:
    - path: Funeralzone\FAS\Common\ValueObjects\Decorators\MediaIdDecoratorTrait
      hooks:
      - type: constructor
        method: decoratorConstruct

  - name: MediaUploadRequestId
    type: String

  - name: ProductId
    type: Uuid

  - name: ServiceId
    type: Uuid

  - name: StaffMemberId
    type: Uuid

  - name: PackageId
    type: Uuid

  # Telephones
  # --------------------------

  - name: TelephoneNumber
    type: String

  - name: TelephoneCountryCode
    type: String

  - name: Telephone
    type: Telephone

  - name: TelephoneType
    type: Enum
    values:
      - WORK
      - HOME
      - MOBILE
      - FAX

  # Address
  # --------------------------

  - name: AddressLine1
    type: String

  - name: AddressLine2
    type: String

  - name: Town
    type: String

  - name: County
    type: String

  - name: PostCode
    type: String

  - name: CountryCode
    type: ISOAlpha2CountryCode

  - name: GeoLocation
    type: Composite
    children:
      - name: AddressData
        type: String
        propertyName: data
      - name: Geometry
        type: Composite
        propertyName: geometry
        children:
          - name: Latitude
            type: Float
            propertyName: lat
            decorators:
            - path: Funeralzone\FAS\Common\ValueObjects\Decorators\LatitudeDecoratorTrait
              hooks:
              - type: constructor
                method: decoratorConstruct
            testing:
              fromNative: '50.9'
              constructor: '50.9'
          - name: Longitude
            type: Float
            propertyName: lng
            testing:
              fromNative: '50.9'
              constructor: '50.9'
            decorators:
            - path: Funeralzone\FAS\Common\ValueObjects\Decorators\LongitudeDecoratorTrait
              hooks:
              - type: constructor
                method: decoratorConstruct

  # Identity interface
  # --------------------------

  - name: IdentityInterfacePolicyMembership
    type: String

  - name: IdentityInterfacePolicyScope
    type: String

  - name: IdentityInterface
    type: Composite
    children:
      - name: IdentityInterfaceType
        type: Enum
        propertyName: type
        values:
          - STAFF_MEMBER
          - DEVELOPER
      - name: IdentityInterfaceName
        type: String
        propertyName: name
      - name: IdentityInterfaceImage
        type: String
        propertyName: image
      - name: IdentityInterfaceEmail
        type: Email
        propertyName: email
      - name: IdentityInterfacePolicy
        type: Composite
        propertyName: policy
        children:
          - name: IdentityInterfacePolicyMemberships
            type: Set
            propertyName: memberships
            modelToEnforce: IdentityInterfacePolicyMembership

          - name: IdentityInterfacePolicyScopes
            type: Set
            propertyName: scopes
            modelToEnforce: IdentityInterfacePolicyScope

  # Other
  # --------------------------

  - name: Note
    type: Entity
    children:
    - name: EntityId
      propertyName: id
    - name: NoteTimeCreated
      type: RFC3339
      propertyName: timeCreated
    - name: NoteContent
      type: String
      propertyName: content
    - name: NoteAuthorId
      type: Uuid
      propertyName: authorId

  - name: Notes
    type: EntitySet
    modelToEnforce: Note

  - name: Name
    type: Composite
    children:
      - name: NameTitle
        type: String
        propertyName: title
      - name: GivenName
        type: String
        propertyName: givenName
      - name: FamilyName
        type: String
        propertyName: familyName

  - name: PersonPhone
    type: TelephoneContact
    typeValues:
    - WORK
    - HOME
    - MOBILE
    - FAX

  - name: PersonEmail
    type: Email

  - name: Person
    type: Composite
    children:
      - name: Name
        propertyName: name

      - name: PersonAddress
        type: Address
        propertyName: address

      - name: PersonPhones
        type: Set
        propertyName: phones
        modelToEnforce: PersonPhone

      - name: PersonEmails
        type: Set
        propertyName: emails
        modelToEnforce: PersonEmail

      - name: MediaId
        propertyName: image

  - name: DirectoryListingIds
    type: Set
    modelToEnforce: DirectoryListingId

  - name: OrganisationalUnitId
    type: Uuid

  - name: OrganisationalUnitIds
    type: Set
    modelToEnforce: OrganisationalUnitId

  - name: EstimateId
    type: Uuid

  - name: EstimateIds
    type: Set
    modelToEnforce: EstimateId

  - name: Tag
    type: String
    decorators:
    - path: Funeralzone\FAS\Common\ValueObjects\Decorators\TagDecoratorTrait
      hooks:
      - type: constructor
        method: decoratorConstruct

  - name: Tags
    type: Set
    decorators:
    - path: Funeralzone\FAS\Common\ValueObjects\Decorators\TagsDecoratorTrait
    modelToEnforce: Tag

  - name: PaginationInput
    type: Composite
    children:
      - name: PaginationInputPage
        type: Integer
        propertyName: page
      - name: PaginationInputNodesPerPage
        type: Integer
        propertyName: nodesPerPage

  - name: StaffRoleId
    type: Uuid

  - name: StaffRoleIds
    type: Set
    modelToEnforce: StaffRoleId

  - name: DeveloperId
    type: Uuid

  - name: DeveloperIds
    type: Set
    modelToEnforce: DeveloperId

  - name: PersonDelta
    type: Delta
    children:
      - name: Name
        propertyName: name
      - name: PersonAddress
        propertyName: address
      - name: PersonPhones
        propertyName: phones
      - name: PersonEmails
        propertyName: emails
      - name: MediaId
        propertyName: image
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~81 days

Total

20

Last Release

2258d ago

Major Versions

0.0.5 → 1.002018-11-19

1.0.7 → 2.0.02019-03-04

2.1.2 → 3.0.02019-07-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b09bb0d934ff8376333a843fcd66ab8c91b5558227adc7956be35607c2fd7ee?d=identicon)[james.sanders](/maintainers/james.sanders)

---

Top Contributors

[![jsandersuk](https://avatars.githubusercontent.com/u/22774080?v=4)](https://github.com/jsandersuk "jsandersuk (10 commits)")[![ganey](https://avatars.githubusercontent.com/u/1401832?v=4)](https://github.com/ganey "ganey (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/funeralzone-valueobject-generator/health.svg)

```
[![Health](https://phpackages.com/badges/funeralzone-valueobject-generator/health.svg)](https://phpackages.com/packages/funeralzone-valueobject-generator)
```

###  Alternatives

[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41716.4k2](/packages/lullabot-drainpipe)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
