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

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

ailixter/gears-value
====================

The project that gears values

0.1.2(2y ago)013.6k↓50%MITPHPPHP &gt;=7.1

Since Aug 10Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)DependenciesVersions (5)Used By (0)

gears-values
============

[](#gears-values)

The project that gears values.

1. Value class implements \[value, error\] pattern.
2. It proposes simple and clear ValueInterface.
3. It provides protected validation method to override.
4. And simple rules
    - value may only be constructed, not set
    - invalid value cannot be constructed
    - value with errors cannot be returned
    - you can get both if you're willing to

Basic Usage
-----------

[](#basic-usage)

```
    use Ailixter\Gears\IntValue;
    use Ailixter\Gears\ValueInterface;

    class Positive extends IntValue
    {
        protected function validate()
        {
            if ($this->getValue() < 1) {
                $this->addError('value', 'is not positive');
            }
        }
    }

    function calculate(int $int): Positive
    {
        $result = new Positive($int * $int);
        if ($result->getValue() > 81) {
            $result->addError('value', 'too big');
        }
        return $result;
    }

    function readyForUnexpected(IntValue $int)
    {
        if ($int->getErrors()) {
            $result = 81;
        } else {
            $result = $int->getValue();
        }
        echo $result - 1;
    }

    function wantNoUnexpected(int $int)
    {
        echo $int - 1;
    }

    readyForUnexpected(calculate(8));       // 63
    readyForUnexpected(calculate(10));      // 80

    wantNoUnexpected(calculate(8)->get());  // 63

    try {
        wantNoUnexpected(calculate(10)->get()); // exception - too big
    } catch (Ailixter\Gears\Exceptions\ValueException $ve) {
        echo PHP_EOL, $ve->getMessage(), ': ';
        print_r($ve->getValue()->getErrors());
    }
    try {
        calculate(0);                      // exception - not positive
    } catch (Ailixter\Gears\Exceptions\ValueException $ve) {
        echo PHP_EOL, $ve->getMessage(), ': ';
        print_r($ve->getValue()->getErrors());
    }
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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 ~559 days

Total

4

Last Release

786d ago

PHP version history (2 changes)0.0.1PHP ^7.1

0.1.2PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/d75f48a062262cb8bb0e9b241ec74bc7363ed041c9eba8fd40d36e7fd3e52ca5?d=identicon)[ailixter](/maintainers/ailixter)

---

Top Contributors

[![ailixter](https://avatars.githubusercontent.com/u/8529462?v=4)](https://github.com/ailixter "ailixter (14 commits)")

### Embed Badge

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

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

PHPackages © 2026

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