Skip to content

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

License

Notifications You must be signed in to change notification settings

codekandis/constants-classes-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codekandis/constants-classes-translator

Version License Minimum PHP Version Code Coverage

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

Index

Installation

Install the latest version with

$ composer require codekandis/constants-classes-translator

How to use

Define some error codes and error messages

abstract class ErrorCodes
{
    public const int ERROR_ONE   = 1;
    public const int ERROR_TWO   = 2;
    public const int ERROR_THREE = 3;
}

abstract 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.';
}
( new ConstantsClassesTranslator( ErrorCodes::class, ErrorMessages::class ) )
    ->translate( ErrorCodes::ERROR_TWO );
/**
 * Error two occured.
 */

or vice versa

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

Exceptions

The ConstantsClassesTranslator throws several exceptions which inherits from ConstantsClassesTranslatorException.

About

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

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published