phpyii/php-utils

php积累的一些公用类方法

dev-master 2021-04-08 02:21 UTC

This package is auto-updated.

Last update: 2024-05-08 09:10:43 UTC


README

php积累的一些公用类方法

环境支持

php版本 >= PHP 7.1

安装

composer require phpyii/php-utils

//开发版本
composer require phpyii/php-utils:dev-master

枚举类使用方法

 class  statusEnum extends \phpyii\utils\Enum{
      const VIEW = 'view';
      const EDIT = 'edit';

      protected static function labels(): array {
          return [
              self::VIEW => '视图',
          ];
      }

 }

 
 
 //枚举值
 $viewAction = statusEnum::VIEW();
 $viewAction->getValue();
 //或者
 statusEnum::VIEW;

 //获取枚举label
 statusEnum::getLabelByValue(statusEnum::VIEW);

 //获取枚举 值=>label数组
 statusEnum::toArray();