codekandis/constants-classes-translator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codekandis/constants-classes-translator

Composer 安装命令:

composer require codekandis/constants-classes-translator

包简介

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

README 文档

README

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

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

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

The ConstantsClassesTranslator throws several exceptions.

统计信息

  • 总下载量: 610
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固