PHPackages                             imunew/laravel-value-objects - 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. imunew/laravel-value-objects

ActiveLibrary

imunew/laravel-value-objects
============================

0.2(5y ago)038MITPHPPHP ^7.0|^8.0

Since Dec 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/imunew/laravel-value-objects)[ Packagist](https://packagist.org/packages/imunew/laravel-value-objects)[ RSS](/packages/imunew-laravel-value-objects/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

laravel-value-objects
=====================

[](#laravel-value-objects)

[![CircleCI](https://camo.githubusercontent.com/5e50134d455f8eb78c8c668d9be584f2e421b1885132004e4353333a434b31b2/68747470733a2f2f636972636c6563692e636f6d2f67682f696d756e65772f6c61726176656c2d76616c75652d6f626a656374732e7376673f7374796c653d737667)](https://circleci.com/gh/imunew/laravel-value-objects)
This package provides abstract Value Object (immutable) class and `make:value-object` command.

```
$ composer require imunew/laravel-value-objects
```

abstract Value Object (immutable) class
---------------------------------------

[](#abstract-value-object-immutable-class)

The abstract ImmutableObject class has the following features.

- Inspired by Laravel's Eloquent Model
- Accessors (`get{Attribute}Attribute` method)
- Data is set only in the constructor

```
namespace Imunew\Laravel\ValueObjects;

/**
 * Interface Immutable
 * @package Imunew\Laravel\ValueObjects
 */
interface Immutable
{
    /**
     * @param string $name
     * @return bool
     */
    public function has(string $name);

    /**
     * @param string $name
     * @param mixed|null $default
     * @return mixed
     */
    public function get(string $name, $default = null);
}
```

`make:value-object` command
---------------------------

[](#makevalue-object-command)

You can create a ValueObject by executing the command as follows.

```
$ php artisan make:value-object {name}
```

Example 1 (`Range`)
-------------------

[](#example-1-range)

```
namespace App\ValueObjects;

use Imunew\Laravel\ValueObjects\ImmutableObject;

class Range extends ImmutableObject
{
    /**
     * Range constructor.
     * @param int $start
     * @param int $end
     * @param int $step
     */
    public function __construct(int $start, int $end, int $step = 1)
    {
        $this->setAttribute('start', $start);
        $this->setAttribute('end', $end);
        $this->setAttribute('step', $step);
    }

    /**
     * @return array
     */
    public function getRangeAttribute()
    {
        return range($this->start, $this->end, $this->step);
    }
}
```

```
$range = new Range(1, 10);
echo $range;
// [1,2,3,4,5,6,7,8,9,10]
```

Example 2 (`DirectoryTree`)
---------------------------

[](#example-2-directorytree)

```
namespace App\ValueObjects;

use Imunew\Laravel\ValueObjects\ImmutableObject;

class DirectoryTree extends ImmutableObject
{
    /**
     * Range constructor.
     * @param array $directoryTree
     */
    public function __construct(array $directoryTree)
    {
        $this->attributes = $directoryTree;
    }
}
```

```
$directoryTree = new DirectoryTree([
    'app' => [
        'Http' => [
            'Controllers' => [],
            'Middleware' => [],
            'Requests' => [],
            'Resources' => [],
        ],
        'ValueObjects' => []
    ]
]);

echo json_encode($directoryTree->get('app.Http'));
// {"Controllers":[],"Middleware":[],"Requests":[],"Resources":[]}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~0 days

Total

2

Last Release

1964d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3860526?v=4)[Motohiro Imura](/maintainers/imunew)[@imunew](https://github.com/imunew)

---

Top Contributors

[![imunew](https://avatars.githubusercontent.com/u/3860526?v=4)](https://github.com/imunew "imunew (6 commits)")

### Embed Badge

![Health badge](/badges/imunew-laravel-value-objects/health.svg)

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

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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