PHP code example of codekandis / constants-classes-translator

1. Go to this page and download the library: Download codekandis/constants-classes-translator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codekandis / constants-classes-translator example snippets


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.
 */

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