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