PHPackages                             webservco/constant-value-class - 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. webservco/constant-value-class

ActiveLibrary

webservco/constant-value-class
==============================

A Constant Value Class implementation

v1.5.1(1y ago)0421MITPHPPHP ^7.4||^8.1

Since Jan 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/webservco/constant-value-class)[ Packagist](https://packagist.org/packages/webservco/constant-value-class)[ Docs](https://webserv.co)[ RSS](/packages/webservco-constant-value-class/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (15)Used By (0)

webservco/constant-value-class
==============================

[](#webservcoconstant-value-class)

A Constant Value Class implementation (enum simulation for PHP 7).

Based on the article ["Expressive, type-checked constants for PHP"](https://www.webfactory.de/blog/expressive-type-checked-constants-for-php).

Note: Only `int` and `string` values are supported.

---

Example
-------

[](#example)

### Constant Value Class

[](#constant-value-class)

Please see `tests/unit/WebServCo/ConstantValueClass/Example.php`

### Usage

[](#usage)

```
class Shipment
{
    public function send(Type $type): bool
    {
        // ...
    }
}
$shipment = new Shipment();
$shipment->send(Type::import());

// or
$type = 2; // request parameter, user input, etc
$shipment->send(Type::fromValue($type));

// get value (exact type) (eg. for form select)
echo Type::import()->value(); // outputs "1"

// get string representation of value
echo Type::import(); // outputs "1"

// comparison
$import = Type::fromValue(2);
if (Type::import() === $import) {
    // === works as long as the object is created in the current script run,
    // not for example created elsewhere and stored serialized in session.
}
```

---

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

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

Recently: every ~189 days

Total

14

Last Release

686d ago

PHP version history (2 changes)v1.0.0PHP ^7.4

v1.5.0PHP ^7.4||^8.1

### Community

Maintainers

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

---

Top Contributors

[![ariademur](https://avatars.githubusercontent.com/u/34913107?v=4)](https://github.com/ariademur "ariademur (55 commits)")

---

Tags

webservco

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webservco-constant-value-class/health.svg)

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

PHPackages © 2026

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