PHPackages                             fleshgrinder/value-object - 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. fleshgrinder/value-object

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

fleshgrinder/value-object
=========================

Abstract value object implementation as basis for custom domain value objects.

v0.0.0(10y ago)2631MITPHPPHP &gt;=5.4.0

Since Sep 25Pushed 9y agoCompare

[ Source](https://github.com/Fleshgrinder/php-value-object)[ Packagist](https://packagist.org/packages/fleshgrinder/value-object)[ RSS](/packages/fleshgrinder-value-object/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/0574d9f0b8f43e2ca5244d8cc5b9f120f75eac5ec0e5a2ad5d259fa5d29d03f3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f466c6573686772696e6465722f7068702d76616c75652d6f626a6563742e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Fleshgrinder/php-value-object)[![Code Climate](https://camo.githubusercontent.com/6390af68f57abcd3f0cf047886bab56f0c65fd7d30ba87428bf9ddf5a635688b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f466c6573686772696e6465722f7068702d76616c75652d6f626a6563742f6261646765732f6770612e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/Fleshgrinder/php-value-object)[![Test Coverage](https://camo.githubusercontent.com/e73e871644f4e14240bd731242ec9545dfd5dd5ae6d8610ab6aeb4934796dc06/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f466c6573686772696e6465722f7068702d76616c75652d6f626a6563742e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/Fleshgrinder/php-value-object/coverage)[![SensioLabsInsight](https://camo.githubusercontent.com/96907002c6e5df696d5ccf468e8784808a963bba5aa1bb17cde489d6726822f2/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f35313239373564392d356364302d346636352d393333342d3331626265373332643664652e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/512975d9-5cd0-4f65-9334-31bbe732d6de)[![Packagist](https://camo.githubusercontent.com/57d2fd4db4411cd8e5ddaa551794635f68cfc63350cd85a476257311a278221c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f466c6573686772696e6465722f76616c75652d6f626a6563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fleshgrinder/value-object)[![Packagist License](https://camo.githubusercontent.com/b0e3596e7a3a178885e5016ef68b0c26cd5211300108013ea64017b659df91ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f466c6573686772696e6465722f76616c75652d6f626a6563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fleshgrinder/value-object)[![VersionEye](https://camo.githubusercontent.com/1799304bc4014c60fd0c83237a9dc49cf9924ab083d8d16fe525a0dea0fda2b0/68747470733a2f2f696d672e736869656c64732e696f2f76657273696f6e6579652f642f757365722f70726f6a656374732f3536303732346239356132363266303031613030303136392e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/560724b95a262f001a000169)

Value Object
============

[](#value-object)

Abstract **value object** package that contains the building blocks to create custom domain value objects.

Install
-------

[](#install)

Open a terminal, enter your project directory and execute the following command to add this package to your dependencies:

```
$ composer require fleshgrinder/value-object
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.

Usage
-----

[](#usage)

There are two abstract classes and one interface in the source directory that can be used to build custom domain value objects tailored to the needs of a project. The provided `ValueObject` interface is a head interface that combines some interfaces to adhere to a contract of common methods that every value object should provide. Implementation of this interface is recommended for totally custom behavior.

The `SingleValueObject` is the perfect base for building value objects that are representable by a single value. Simply extend the abstract class and implement the necessary abstract methods and it should work out of the box. You may also extend the `SingleValueObjectTest` and override the `getInstance`, `getDefaultValue`, and `getDefaultUnequalValue`methods for a thorough test of your custom single valued value object.

The `MultiValueObject` is the perfect base for building value objects that represent multiple values. However, it only implements the `equals` method that ensures that the given value is of the same instance and delegates further checks to the extending child class. Multi valued value objects are complex and it is not possible to implement an abstraction that fits all requirements. You may also simply implement the interface and implement the instance of check yourself if you want.

Weblinks
--------

[](#weblinks)

- Wikipedia: [Value Object](https://en.wikipedia.org/wiki/Value_object)
- Mathias Verraes: [Casting Value Objects](http://verraes.net/2013/02/casting-value-objects/)
- Eric Evans (2003): [Domain-Driven Design: Tackling Complexity in the Heart of Software](http://www.domaindrivendesign.org/books/evans_2003)
- Wikipedia: [Domain-Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design)
- Carlos Buenosvinos, Christian Soronellas and Keyvan Akbary: [Domain-Driven Design in PHP](https://leanpub.com/ddd-in-php)

License
-------

[](#license)

[![MIT License](https://camo.githubusercontent.com/f8370bd5022685ccc4cdebd136a849a7692c5afd674e59ca8805d90f2aa29a72/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f632f63332f4c6963656e73655f69636f6e2d6d69742e7376672f343870782d4c6963656e73655f69636f6e2d6d69742e7376672e706e67)](https://opensource.org/licenses/MIT)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3934d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6680298143064cd3ac63c0097ef724d46f47221ae0990db445081c4e8a923e05?d=identicon)[Fleshgrinder](/maintainers/Fleshgrinder)

---

Top Contributors

[![Fleshgrinder](https://avatars.githubusercontent.com/u/1059453?v=4)](https://github.com/Fleshgrinder "Fleshgrinder (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fleshgrinder-value-object/health.svg)

```
[![Health](https://phpackages.com/badges/fleshgrinder-value-object/health.svg)](https://phpackages.com/packages/fleshgrinder-value-object)
```

###  Alternatives

[m2-boilerplate/module-critical-css

Magento 2 module to automatically generate critical css with the addyosmani/critical npm package

3684.7k](/packages/m2-boilerplate-module-critical-css)[jajuma/awesomehyva

This Magento 2 extension allows using Font Awesome 5 icons with Hyvä Themes

1354.7k](/packages/jajuma-awesomehyva)[ijeffro/laravel-cities

Laravel Cities is a bundle for Laravel, providing Iata Code ISO 3166 3 and country codes for all the cities.

118.2k](/packages/ijeffro-laravel-cities)

PHPackages © 2026

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