PHPackages                             xianyu/enum - 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. xianyu/enum

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

xianyu/enum
===========

v1.0.0(6y ago)09MITPHPPHP &gt;=7.3

Since Jun 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/qinshuze/enum)[ Packagist](https://packagist.org/packages/xianyu/enum)[ RSS](/packages/xianyu-enum/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

enum
====

[](#enum)

php枚举

使用方法
====

[](#使用方法)

> Test.php

```
/**
 * Class StatusEnum
 * @method static self OK
 * @method static self LOCK
 */
class StatusEnum extends \Xianyu\Enum\Enum
{
    private const OK   = [1, '正常'];
    private const LOCK = [2, '锁定'];

    /** @var string */
    private $key;
    /** @var string */
    private $value;

    /**
     * StatusEnum constructor.
     * @param string $key
     * @param string $value
     */
    public function __construct(string $key, string $value)
    {
        $this->key = $key;
        $this->value = $value;
    }

    /**
     * @return string
     */
    public function getKey(): string
    {
        return $this->key;
    }

    /**
     * @return string
     */
    public function getValue(): string
    {
        return $this->value;
    }
}

echo StatusEnum::OK()->getKey();    // 1
echo StatusEnum::OK()->getValue();  // 正常
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

2205d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5780449?v=4)[xianyu](/maintainers/xianyu)[@xianyu](https://github.com/xianyu)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/xianyu-enum/health.svg)

```
[![Health](https://phpackages.com/badges/xianyu-enum/health.svg)](https://phpackages.com/packages/xianyu-enum)
```

PHPackages © 2026

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