PHPackages                             kevinpurwito/php-constant - 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. kevinpurwito/php-constant

ActiveLibrary

kevinpurwito/php-constant
=========================

PhpConstant is a simple class containing useful functions which you can extend to your constant classes.

1.2.0(4y ago)12.8k1MITPHPPHP ^7.4|^8.0CI failing

Since Jun 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/kevinpurwito/php-constant)[ Packagist](https://packagist.org/packages/kevinpurwito/php-constant)[ Docs](https://github.com/kevinpurwito/php-constant)[ Fund](https://www.paypal.me/kevinpurwito)[ RSS](/packages/kevinpurwito-php-constant/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (4)Versions (7)Used By (1)

About PhpConstant
=================

[](#about-phpconstant)

[![Tests](https://github.com/kevinpurwito/php-constant/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/kevinpurwito/php-constant/actions/workflows/run-tests.yml)[![Code Style](https://github.com/kevinpurwito/php-constant/actions/workflows/php-cs-fixer.yml/badge.svg?branch=main)](https://github.com/kevinpurwito/php-constant/actions/workflows/php-cs-fixer.yml)[![Psalm](https://github.com/kevinpurwito/php-constant/actions/workflows/psalm.yml/badge.svg?branch=main)](https://github.com/kevinpurwito/php-constant/actions/workflows/psalm.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/b511a022b9eba3cb6bca77e56d27e59312473ea0c9f66ba98103530727e0838e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6576696e7075727769746f2f7068702d636f6e7374616e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kevinpurwito/php-constant)[![Total Downloads](https://camo.githubusercontent.com/d1c6504bcf9032a7010dec9ae4826d97ce7e55a123235706c2c0dba80823fc35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6576696e7075727769746f2f7068702d636f6e7374616e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kevinpurwito/php-constant)

PhpConstant is a simple class containing useful functions which you can extend to your constant classes.

For example if you want to have a StatusConst class, which contains all possible statuses as constants, you can extend PhpConstant to use its functions for your StatusConst class.

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

[](#installation)

You can install the package via composer:

```
composer require kevinpurwito/php-constant
```

Usage
-----

[](#usage)

```
use KevinPurwito\PhpConstant\PhpConstant;

// Class Extends PhpConstant to use its functions
class StatusConst extends PhpConstant
{
    const PENDING = 'pending';
    const IN_PROCESS = 'in_process';
    const COMPLETED = 'completed';
}

/*
|--------------------------------------------------------------------------
| Framework Agnostic Functions
|--------------------------------------------------------------------------
|
| Simple functions not dependent to any framework and can be used in any PHP project.
|
*/

// returns an array like this: ['pending', 'in_process', 'completed']
StatusConst::all();

// returns a key-value array like this: ['pending' => 'Pending', 'in_process' => 'In Process', 'completed' => 'Completed']
StatusConst::options();

// returns a string like this: 'pending,in_process,completed'
StatusConst::asString();

// You can use any char you want as the glue for asString() function
// returns a string like this: 'pending|in_process|completed'
StatusConst::asString('|');

/*
|--------------------------------------------------------------------------
| Laravel Specific Functions
|--------------------------------------------------------------------------
|
| Functions to support [Laravel Collection](https://laravel.com/docs/collections) class.
| Laravel Collection is a class that provides a fluent, convenient wrapper for working with arrays of data.
|
*/

// returns a collection equivalent to: collect(['pending', 'in_process', 'completed'])
StatusConst::collect();

// returns a key-value collection equivalent to: collect(['pending' => 'Pending', 'in_process' => 'In Process', 'completed' => 'Completed'])
StatusConst::collectOptions();
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email instead of using the issue tracker.

Credits
-------

[](#credits)

- [Kevin Purwito](https://github.com/kevinpurwito)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com)by [Beyond Code](http://beyondco.de/)with some modifications inspired from [PHP Package Skeleton](https://github.com/spatie/package-skeleton-php) by [spatie](https://spatie.be/).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

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

Total

5

Last Release

1710d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/47e3d5e05f33c7b66c0c646fbce5dac5a319a8fd7ebb13977d2a1ae3df91e9a4?d=identicon)[kevinpurwito](/maintainers/kevinpurwito)

---

Top Contributors

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

---

Tags

phpconstantkevinpurwito

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kevinpurwito-php-constant/health.svg)

```
[![Health](https://phpackages.com/badges/kevinpurwito-php-constant/health.svg)](https://phpackages.com/packages/kevinpurwito-php-constant)
```

###  Alternatives

[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)

PHPackages © 2026

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