Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

似乎 getDescription / getComment 更合适? #9

Closed
wi1dcard opened this issue Nov 14, 2018 · 4 comments
Closed

似乎 getDescription / getComment 更合适? #9

wi1dcard opened this issue Nov 14, 2018 · 4 comments

Comments

@wi1dcard
Copy link
Contributor

https://github.com/Yurunsoft/IMI/releases/tag/v0.2.1

// 根据值获得文字说明
Status::getText(Status::YES);
@Yurunsoft
Copy link
Member

命名还是很纠结的事情,我觉得都可以

@wi1dcard
Copy link
Contributor Author

Text 意指文本,文本可以代表的东西就很多了,感觉还是明确一点比较合适

@Yurunsoft
Copy link
Member

这里的作用我认为本来就是模糊的,到底是简约的意思:YES->,还是相当于注释说明:YES->状态是正确的,完全取决于用的人。

另外imi还支持自定义字段,然后获取注解对象来用:

<?php
namespace ImiDemo\HttpDemo\MainServer\Enum;
 
use Imi\Enum\BaseEnum;
use Imi\Enum\Annotation\EnumItem;
 
class Status extends BaseEnum
{
    /**
     * @EnumItem(text="正确", comment="状态是正确的")
     */
    const YES = 1;
 
    /**
     * @EnumItem(text="错误", comment="状态是错误的")
     */
    const NO = 0;
}

// 使用:
echo Status::getData(Status::YES)->comment;

@wi1dcard
Copy link
Contributor Author

好吧,我还是比较赞成 Laravel 的思想,顾名思义,简洁明了。这种看起来扩展性很强的设计会让人觉得无从下手,不得不阅读文档才能明确。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants