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

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

marvin255/value-object
======================

Set of value objects for PHP.

v0.3.2(2mo ago)02011MITPHPPHP &gt;=8.4CI passing

Since Aug 23Pushed 4w agoCompare

[ Source](https://github.com/marvin255/value-object)[ Packagist](https://packagist.org/packages/marvin255/value-object)[ RSS](/packages/marvin255-value-object/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (15)Versions (19)Used By (1)

Value objects
=============

[](#value-objects)

[![Latest Stable Version](https://camo.githubusercontent.com/1c98933d23a356d2c10a4491a44cdfcacf6427382fa9de99b1fd4de8e79ffb05/68747470733a2f2f706f7365722e707567782e6f72672f6d617276696e3235352f76616c75652d6f626a6563742f76)](https://packagist.org/packages/marvin255/value-object)[![Total Downloads](https://camo.githubusercontent.com/d840b16a57f869d8b54f1527416901745a29bb1634569dff7b2e8bda450c7f13/68747470733a2f2f706f7365722e707567782e6f72672f6d617276696e3235352f76616c75652d6f626a6563742f646f776e6c6f616473)](https://packagist.org/packages/marvin255/value-object)[![License](https://camo.githubusercontent.com/f7bb2a6f4a82c1e51ebbeb6cd1de6974d563bb5c494807d275fc97f6c81f9f73/68747470733a2f2f706f7365722e707567782e6f72672f6d617276696e3235352f76616c75652d6f626a6563742f6c6963656e7365)](https://packagist.org/packages/marvin255/value-object)[![Build Status](https://github.com/marvin255/value-object/workflows/marvin255_value_object/badge.svg)](https://github.com/marvin255/value-object/actions?query=workflow%3A%22marvin255_value_object%22)

A collection of type-safe value objects for PHP 8.3+ with built-in validation. Includes email, URI, integer, string, and file info objects designed for domain-driven development.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require marvin255/value-object
```

Usage
-----

[](#usage)

### String Value Objects

[](#string-value-objects)

Create type-safe string values with optional constraints:

```
use Marvin255\ValueObject\StringValueObject;
use Marvin255\ValueObject\StringNonEmptyValueObject;

// Basic string value object
$name = new StringValueObject('John Doe');
echo $name->value(); // "John Doe"

// String that cannot be empty
$title = new StringNonEmptyValueObject('Developer');
echo $title->value(); // "Developer"
```

### Integer Value Objects

[](#integer-value-objects)

Work with integers using type-safe value objects:

```
use Marvin255\ValueObject\IntValueObject;
use Marvin255\ValueObject\IntPositiveValueObject;
use Marvin255\ValueObject\IntNonNegativeValueObject;
use Marvin255\ValueObject\IntNegativeValueObject;
use Marvin255\ValueObject\IntNonPositiveValueObject;

// Any integer
$count = new IntValueObject(-5);
echo $count->value(); // -5

// Positive integer only (> 0)
$age = new IntPositiveValueObject(25);
echo $age->value(); // 25

// Non-negative integer (>= 0)
$score = new IntNonNegativeValueObject(0);
echo $score->value(); // 0

// Negative integer only (< 0)
$debt = new IntNegativeValueObject(-100);
echo $debt->value(); // -100

// Non-positive integer (value(); // -5
```

### Float Value Objects

[](#float-value-objects)

Work with floating-point numbers safely:

```
use Marvin255\ValueObject\FloatValueObject;

// Any float value
$price = new FloatValueObject(19.99);
echo $price->value(); // 19.99
```

### BCMath Value Object

[](#bcmath-value-object)

Arbitrary-precision decimal numbers using BcMath:

```
use Marvin255\ValueObject\BcMathNumberValueObject;

$file = new BcMathNumberValueObject('123.123123');
echo $empty->value(); // "123.123123"
```

### Percentage Value Object

[](#percentage-value-object)

Work with percentage values (0-100) safely:

```
use Marvin255\ValueObject\PercentageValueObject;

// Percentage between 0 and 100
$progress = new PercentageValueObject(75.5);
echo $progress->value(); // 75.5

$complete = new PercentageValueObject(100);
echo $complete->value(); // 100

$empty = new PercentageValueObject(0.0);
echo $empty->value(); // 0

// Decimal precision supported
$accuracy = new PercentageValueObject(99.99);
echo $accuracy->value(); // 99.99

// This will throw an exception
// new PercentageValueObject(101); // throws InvalidArgumentException
```

### Email Value Object

[](#email-value-object)

Validate and use email addresses:

```
use Marvin255\ValueObject\EmailValueObject;

$email = new EmailValueObject('user@example.com');
echo $email->value(); // "user@example.com"
```

### URI Value Object

[](#uri-value-object)

Create validated URI objects:

```
use Marvin255\ValueObject\UriValueObject;

$uri = new UriValueObject('https://example.com/path?query=value');
echo $uri->value(); // "https://example.com/path?query=value"
```

### File Info Value Object

[](#file-info-value-object)

Work with file information safely:

```
use Marvin255\ValueObject\FileInfoValueObject;

$file = new FileInfoValueObject('/path/to/file.txt');
echo $file->value()->getPathname(); // "/path/to/file.txt"
echo $file->getMimeType();          // "text/plain"
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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 ~19 days

Recently: every ~1 days

Total

13

Last Release

89d ago

PHP version history (2 changes)v0.1.0PHP &gt;=8.3

v0.3.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c29b776ac327dcfcdfc20619a65826ad94a0cb554503386fb080299edfbe3e8?d=identicon)[marvin255](/maintainers/marvin255)

---

Top Contributors

[![marvin255](https://avatars.githubusercontent.com/u/2802915?v=4)](https://github.com/marvin255 "marvin255 (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

phpphp-libraryvalue-objectphpValue Object

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[aimeos/aimeos-base

Aimeos base layer for abstracting from host environments

2.2k147.3k3](/packages/aimeos-aimeos-base)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[anthropic-ai/sdk

Anthropic PHP SDK

163583.3k17](/packages/anthropic-ai-sdk)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)

PHPackages © 2026

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