PHPackages                             php-libs/value-states - 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. php-libs/value-states

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

php-libs/value-states
=====================

Extends php-libs/observer to track if a values have been initialized or modified (changed after initialization)

1.3(4y ago)0110MITPHPPHP ^8.0

Since May 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/php-libs/value-state)[ Packagist](https://packagist.org/packages/php-libs/value-states)[ RSS](/packages/php-libs-value-states/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

PhpLibs\\Observable
===================

[](#phplibsobservable)

This package contains a simple set of classes to facilitate adding observers to property methods.

Features
========

[](#features)

- Execute `callable` before any value changes
- Execute `callable` before specific values change
- Execute `callable` after any value changes
- Execute `callable` after specific values change

Quick Start
===========

[](#quick-start)

Install
-------

[](#install)

`composer require php-libs/observable`

Example Class Without Observable Properties
-------------------------------------------

[](#example-class-without-observable-properties)

```
class MyClass
{
    private ?string $propertyA = null;

    private ?string $propertyB = null;

    public function setPropertyA(string $value)
    {
        $this->propertyA = $value;
    }

    public function setPropertyB(string $value)
    {
        $this->propertyB = $value;
    }
}
```

Example Class With Observable Properties
----------------------------------------

[](#example-class-with-observable-properties)

```
class MyClass implements \PhpLibs\Observable\BeforeValueChangeObservableInterface
{
    private const PROPERTY_A = 'propertyA';
    private const PROPERTY_B = 'propertyB';

    use PhpLibs\Observable\BeforeValueChangeObservableTrait;
    use PhpLibs\Observable\AfterValueChangeObservableTrait;

    private ?string $propertyA = null;

    private ?string $propertyB = null;

    public function setPropertyA(string $value)
    {
        $this->raiseBeforeValueChange(static::PROPERTY_A, $this->propertyA, $value);
        $this->propertyA = $value;
        $this->raiseAfterValueChange(static::PROPERTY_A, $this->propertyA);
    }

    public function setPropertyB(string $value)
    {
        $this->raiseBeforeValueChange(static::PROPERTY_B, $this->propertyB, $value);
        $this->propertyB = $value;
        $this->raiseAfterValueChange(static::PROPERTY_B, $this->propertyB);
    }
}
```

Full Example
------------

[](#full-example)

Please see [example.php](examples/example.php)

Which outputs as follows:

```
propertyA WILL CHANGE from "" to "A-1"
propertyB WILL CHANGE from "" to "B-1"
Begin observing After B Changed
propertyA WILL CHANGE from "A-1" to "A-2"
propertyB WILL CHANGE from "B-1" to "B-2"
propertyB CHANGED to "B-2"
End observing After B Changed
propertyA WILL CHANGE from "A-2" to "A-3"
propertyB WILL CHANGE from "B-2" to "B-3"

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Total

6

Last Release

1816d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/25214e6c9e77b2b49c7f9f22e66ae248542d1e28ace60952c79c9720423f6054?d=identicon)[AdamLenda](/maintainers/AdamLenda)

---

Top Contributors

[![AdamLenda](https://avatars.githubusercontent.com/u/2902383?v=4)](https://github.com/AdamLenda "AdamLenda (7 commits)")

### Embed Badge

![Health badge](/badges/php-libs-value-states/health.svg)

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

###  Alternatives

[spiral/mcp-server

Spiral bridge for MCP server

541.1k2](/packages/spiral-mcp-server)

PHPackages © 2026

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