patr1k/phenum 问题修复 & 功能扩展

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

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

patr1k/phenum

Composer 安装命令:

composer require patr1k/phenum

包简介

PHP Enumerator

关键字:

README 文档

README

How It Works

Unlike most enumerators which use an abstract class as a domain container, Phenum is a trait which can be attached to any class where the enumerated domain is expressed as constants.

Advantages

  • By representing enums using scalar constants rather than objects, this approach is slightly faster and more memory efficient than OO-based approaches.
  • Enums are more tightly coupled with the class to which they belong, which can make the code easier to read for developers who are new to your project.

Disadvantages

  • Without using objects to represent enums, the auto-complete feature in your IDE won't know what the possible enum values are for a given domain. You would need to know which class defines the domain values, then begin typing the domain prefix to see the possible values.
<?php
use Patr1k\Phenum;

class Person {
    use Phenum\Enum;
    
    /**
     * @var string
     */
    protected $gender;
    
    const GENDER_MALE        = 'M';
    const GENDER_FEMALE      = 'F';
    const GENDER_UNSPECIFIED = 'U';
    
    /**
     * @return string
     */
    public function getGender() {
        return $this->gender;
    }
    
    /**
     * @param  string $gender
     * @throws Phenum\DomainException
     */
    public function setGender($gender) {
        $this->gender = self::validateEnum($gender, 'GENDER');
    }
}

Requirements

  • PHP >= 5.6.0

License

MIT License see LICENSE file

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固