ronildo-sousa/enumer 问题修复 & 功能扩展

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

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

ronildo-sousa/enumer

最新稳定版本:v0.0.1

Composer 安装命令:

composer require ronildo-sousa/enumer

包简介

A simple package to create PHP enum from a json file

README 文档

README

Latest Version on Packagist Total Downloads

A simple package to create PHP enum from a Json.

Installation

You can install the package via composer:

composer require ronildo-sousa/enumer

Usage

$json = '{"Hearts": "H", "Diamonds": "D", "Clubs": "C", "Spades": "S"}';

$enumer = new RonildoSousa\Enumer();
$enumer->convertJson(json: $json, file_path: '/Enums/Test.php');

It will create a class like this:

enum Test: string
{
    
   case Hearts = "H";

   case Diamonds = "D";

   case Clubs = "C";

   case Spades = "S";

}

You can change the return type of the enum:

$json = '{"Guest": 1, "Editor": 2, "Admin": 3, "Owner": 4}';

$enumer = new RonildoSousa\Enumer();
$enumer->convertJson(json: $json, file_path: '/Enums/Test.php', returnType: 'int');

It will create a class like this:

enum Test: int
{
    
   case Guest = 1;

   case Editor = 2;

   case Admin = 3;

   case Owner = 4;

}

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-17