bulychev/enums 问题修复 & 功能扩展

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

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

bulychev/enums

最新稳定版本:1.1.1

Composer 安装命令:

composer require bulychev/enums

包简介

Enums Helper Traits for PHP 8.1+

README 文档

README

Enums Helper Traits for PHP 8.1+ ❤

Installation

composer require bulychev/enums

Usage trait

/**
 * @method static int USER()
 * @method static int ADMIN()
 * @method static int ROOT()
 */
#[Property(Description::class)]
enum Role: int
{
    use EnumsHelper;

    #[Description('Standard user account')]
    case USER = 10;

    #[Description('User with advanced permissions')]
    case ADMIN = 50;

    #[Description('User with full permissions')]
    case ROOT = 99;
}

__invoke & __callStatic: int|string

BackedEnum

Role::ADMIN(); // int(50)
Role::ROOT(); // int(99)
Role::MANAGER(); // throw new UndefinedEnumCaseException

UnitEnum

/**
 * @method static string RU()
 * @method static string KG()
 * @method static string EN()
 */
enum Lang
{
    use EnumsHelper;
    
    case RU;
    case KG;
    case EN;
}
Role::RU(); // string(2) "RU"
Role::KG(); // string(2) "KG"
Role::EN(); // string(2) "EN"

names(): array

Role::names();
// array(3) {
//   [0]=> string(4) "USER"
//   [1]=> string(5) "ADMIN"
//   [2]=> string(4) "ROOT"
// }

values(): array

Role::values();
// array(3) {
//   [0]=> int(10)
//   [1]=> int(50)
//   [2]=> int(99)
// }

array(): array

Role::array();
// array(3) {
//   [10]=> string(4) "USER"
//   [50]=> string(5) "ADMIN"
//   [99]=> string(4) "ROOT"
// }

description(): ?string

Role::ROOT->description();
// string(26) "User with full permissions"

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固