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

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

tmilos/value
============

Abstract value and enum objects

2.0.1(9y ago)31.7M—7.5%3MITPHPPHP &gt;=5.6.0

Since Apr 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/tmilos/value)[ Packagist](https://packagist.org/packages/tmilos/value)[ RSS](/packages/tmilos-value/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (3)

Value object PHP lib
====================

[](#value-object-php-lib)

Abstract value and enum objects

[![License](https://camo.githubusercontent.com/11f63f5e408c634ff81840555763f32f5869fc88673082bf48c124c019c93209/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746d696c6f732f76616c75652e737667)](https://packagist.org/packages/tmilos/value)[![Build Status](https://camo.githubusercontent.com/f4286dbfdc4b1a27eb021e8293b3cdd6d24dceb365c7283b84075596a4dc2587/68747470733a2f2f7472617669732d63692e6f72672f746d696c6f732f76616c75652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tmilos/value)[![Coverage Status](https://camo.githubusercontent.com/8c2cd3d0dc78d575cd370e11b0adae7b75c874595714653dc59c79f25e1075ef/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f746d696c6f732f76616c75652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/tmilos/value?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ef9dc286d77dda24e516915328950d83a9e0bf53322df43f1f425a4ec0218b46/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746d696c6f732f76616c75652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/tmilos/value/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/266db7720e66488229e283040ef1dda42da7ac4b60ed25185c48c31c682fa155/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33666136356332342d643231302d343332392d623966342d6561323235646561363933392f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/3fa65c24-d210-4329-b9f4-ea225dea6939)

Value objects
-------------

[](#value-objects)

```
class IntValue extends AbstractValue
{
    public static function isValid($value)
    {
        return is_int($value);
    }
}

$x = new IntValue(10); // ok
print $x->getValue(); // 10
$y = new IntValue(10);
var_dump($x->equal($y)); // true

$z = new IntValue('20'); // throws \UnexpectedValueException
```

Enum value object
-----------------

[](#enum-value-object)

All class defined constants are valid values, and magic method with same constant name can be called to instantiate Enum with that value.

```
class Gender extends AbstractEnum
{
    const MALE = 'male';
    const FEMALE = 'female';

    private static $titles = [
        self::MALE => 'gender.male',
        self::FEMALE => 'gender.female',
    ];

    public function getTitle()
    {
        return self::$titles[$this->getValue()];
    }
}

var_dump(Gender::all());    // ['male' => Gender() => 'female' => Gender() ]
var_dump(Gender::values()); // [ 0 => 'male', 1 => 'female' ]
$m = Gender::MALE();
print $m->getValue(); // male
print $m->getTitle(); // gender.male
var_dump(Gender::isValid('male')); // true
var_dump(Gender::isValid('something')); // false
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~52 days

Recently: every ~65 days

Total

6

Last Release

3431d ago

Major Versions

0.1.0 → 1.0.02016-04-12

1.0.2 → 2.0.02016-12-21

PHP version history (2 changes)0.1.0PHP &gt;=5.5.1

2.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e5954d541c3e6ce57f3674bd4ce58bf22629f70b8e8a8779aec754787d26e7e?d=identicon)[tmilos](/maintainers/tmilos)

---

Top Contributors

[![tmilos](https://avatars.githubusercontent.com/u/1818373?v=4)](https://github.com/tmilos "tmilos (19 commits)")

---

Tags

enumabstract value object

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[myclabs/php-enum

PHP Enum implementation

2.7k227.9M637](/packages/myclabs-php-enum)[dasprid/enum

PHP 7.1 enum implementation

382146.0M11](/packages/dasprid-enum)[spatie/enum

PHP Enums

84529.1M68](/packages/spatie-enum)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49644.8M97](/packages/marc-mabe-php-enum)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[consistence/consistence

Consistence - consistent approach and additions to PHP's functionality

1831.1M18](/packages/consistence-consistence)

PHPackages © 2026

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