PHPackages                             rsmike/label - 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. rsmike/label

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

rsmike/label
============

A simple way to organise constant collections and constant=&gt;string dictionaries.

1.1.2(6y ago)066MITPHP

Since Sep 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/rsmike/label)[ Packagist](https://packagist.org/packages/rsmike/label)[ RSS](/packages/rsmike-label/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (10)Used By (0)

PHP Labels
==========

[](#php-labels)

A simple way to organise constant collections and constant=&gt;string dictionaries.

### Example label class:

[](#example-label-class)

```
/**
 * An example label class.
 *
 * @method static string|array status($item = [])
 * @method static string|array abbr($item = [])
 */

abstract class TestLabels extends rsmike\label\Label
 {
    const INACTIVE = 0;
    const ACTIVE = 1;
    const OTHER = 3;

    protected static $status = [
        self::ACTIVE => 'Active',
        self::INACTIVE => 'Inactive',
        self::OTHER => 'Other',
    ];

    protected static $abbr = [
        self::ACTIVE => 'A',
        self::INACTIVE => 'I'
    ];
 }
```

#### Notes:

[](#notes)

- make sure to declare '@method static' PHPDoc for autocomplete to work
- classes should be declared abstract to avoid instantiation

### Usage:

[](#usage)

`TestLabels::status(TestLabels::ACTIVE);` Returns: 'Active'

`TestLabels::abbr(0);` Returns: 'I'

`TestLabels::status(2);` Returns: 2 (pass-through)

`TestLabels::status(3);` Returns: 'Other'

`TestLabels::status(null);` Returns: null (pass-through)

`TestLabels::status();` Returns: \[1=&gt;'Active', 0=&gt;'Inactive'\] (complete set of options. Useful for dropdowns etc. )

`TestLabels::status([]);` Returns: \[1=&gt;'Active', 0=&gt;'Inactive'\] (same as above)

`TestLabels::status([0]);` Returns: \[1, 0\] (all available keys)

`TestLabels::status([[0, 3]]);` Returns: \[0=&gt;'Inactive', 3=&gt;'Other'\] (subset)

#### Default value:

[](#default-value)

An additional parameter may be passed as a default value instead of pass-through:

`TestLabels::status(2, 'N/A');` Returns: 'N/A' (key not found)

`TestLabels::status(null, 'N/A');` Returns: 'N/A' (always returns default value on null)

#### Yes/No:

[](#yesno)

YN method is a built-in example and may be used in any sub-class `TestLabels::YN(1)` Returns: 'Yes'

$YN is protected and may be overridden in a subclass.

Installation
------------

[](#installation)

Either run

```
$ composer require rsmike/label:~1.1
```

or add

```
"rsmike/label": "~1.1"

```

to the `require` section of your `composer.json` file.

### Changelog

[](#changelog)

##### v1.1

[](#v11)

- Subset functionality

##### v1.0

[](#v10)

- YN is now builtin
- label() method removed
- Fallback value functionality

##### v0.3.4

[](#v034)

- changed default shortcuts to `[]` and `[0]`

##### v0.3.4

[](#v034-1)

- array keys shortcut

##### v0.3

[](#v03)

- dev version

### TODO

[](#todo)

- tests

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

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

Recently: every ~221 days

Total

9

Last Release

2278d ago

Major Versions

0.3.6 → 1.02018-12-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ad20ee9b6a35d398aca3ca4cc3b802786991cb00630562ce45209478dfbc468?d=identicon)[rsmike](/maintainers/rsmike)

---

Top Contributors

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

---

Tags

phpdictionarylabelconstant

### Embed Badge

![Health badge](/badges/rsmike-label/health.svg)

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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