PHPackages                             codekandis/constants-classes-translator - 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. codekandis/constants-classes-translator

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

codekandis/constants-classes-translator
=======================================

`codekandis/constants-classes-translator` is a library to translate values from constants classes into values of another constants classes.

2.0.0(7mo ago)16084MITPHPPHP &gt;=8.4CI failing

Since Jan 16Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/codekandis/constants-classes-translator)[ Packagist](https://packagist.org/packages/codekandis/constants-classes-translator)[ RSS](/packages/codekandis-constants-classes-translator/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (2)Dependencies (5)Versions (5)Used By (4)

codekandis/constants-classes-translator
=======================================

[](#codekandisconstants-classes-translator)

[![Version](https://camo.githubusercontent.com/dd1b51eac051b316a3173585bc64d36e19fa2d4e90a4581734cc292c175130f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e302e302d626c75652e737667)](./CHANGELOG.md)[![License](https://camo.githubusercontent.com/07a7d0169027aac6d7a0bfa8964dfef5fbc40d5a2075cabb3d8bc67e17be3451/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f772e737667)](./LICENSE)[![Minimum PHP Version](https://camo.githubusercontent.com/db2abc4c99337a799d57b191c749e512b551eaebf6ce7c37e0ea9eac2eb1b9f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e342d3838393242462e737667)](https://php.net)[![Code Coverage](https://camo.githubusercontent.com/af813ae002de8e31bfd234a3d5eab4fe1963ed998df54d1f3c5e3e1fe334f7d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d677265656e2e737667)](https://camo.githubusercontent.com/af813ae002de8e31bfd234a3d5eab4fe1963ed998df54d1f3c5e3e1fe334f7d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d677265656e2e737667)

`codekandis/constants-classes-translator` is a library to translate values from constants classes into values of another constants classes.

Index
-----

[](#index)

- [Installation](#installation)
- [Testing](#testing)
- [How to use](#how-to-use)
- [Exceptions](#exceptions)

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

[](#installation)

Install the latest version with

```
$ composer require codekandis/constants-classes-translator
```

Testing
-------

[](#testing)

Test the code with

```
$ composer run-script test
```

If you want to retrieve a full coverage report run

```
$ composer run-script test-coverage
```

How to use
----------

[](#how-to-use)

This example demonstrates how to simply translate between error codes and error messages.

First create interfaces or classes containing identical named constants representing error codes and error messages.

```
interface ErrorCodesInterface
{
    public const int ERROR_ONE   = 1;
    public const int ERROR_TWO   = 2;
    public const int ERROR_THREE = 3;
}

class ErrorMessages
{
    public const string ERROR_ONE   = 'Error one occurred.';
    public const string ERROR_TWO   = 'Error two occurred.';
    public const string ERROR_THREE = 'Error three occurred.';
}
```

Next translate error codes into error messages.

```
new ConstantsClassesTranslator( ErrorCodesInterface::class, ErrorMessages::class )
    ->translate( ErrorCodesInterface::ERROR_TWO );
/**
 * Error two occured.
 */
```

Or translate error messages into error codes.

```
new ConstantsClassesTranslator( ErrorMessages::class, ErrorCodesInterface::class )
    ->translate( ErrorMessages::ERROR_TWO );
/**
 * 2
 */
```

Exceptions
----------

[](#exceptions)

The [`ConstantsClassesTranslator`](./src/ConstantsClassesTranslator.php) throws several exceptions.

- [`InterfaceOrClassNotFoundException`](https://github.com/codekandis/types/blob/1.x/src/InterfaceOrClassNotFoundException.php) a passed constants interface or class does not exist
- [`InterfaceOrClassConstantNotFoundException`](https://github.com/codekandis/types/blob/1.x/src/InterfaceOrClassConstantNotFoundException.php) a constant of a specific interface or class does not exist
- [`InterfaceOrClassConstantValueNotFoundException`](https://github.com/codekandis/types/blob/1.x/src/InterfaceOrClassConstantValueNotFoundException.php) a constant with a specific value of a specific interface or class does not exist

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance62

Regular maintenance activity

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity74

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

Total

3

Last Release

233d ago

Major Versions

1.1.0 → 2.0.02025-09-26

PHP version history (2 changes)1.0.0PHP ^7.4

2.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31327217?v=4)[Christian Ramelow](/maintainers/codekandis)[@codekandis](https://github.com/codekandis)

---

Top Contributors

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

---

Tags

classconstantsphptranslatorphpclasstranslatorclassesconstantsconstant

###  Code Quality

Static AnalysisRector

### Embed Badge

![Health badge](/badges/codekandis-constants-classes-translator/health.svg)

```
[![Health](https://phpackages.com/badges/codekandis-constants-classes-translator/health.svg)](https://phpackages.com/packages/codekandis-constants-classes-translator)
```

###  Alternatives

[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[gehrisandro/tailwind-merge-php

TailwindMerge for PHP merges multiple Tailwind CSS classes by automatically resolving conflicts between them

1391.5M9](/packages/gehrisandro-tailwind-merge-php)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)

PHPackages © 2026

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