withinboredom/common-records
最新稳定版本:v0.2.0
Composer 安装命令:
composer require withinboredom/common-records
包简介
Common scalar records
README 文档
README
Install:
composer require withinboredom/common-records
This is a generated collection of common records (see generator.php).
Included:
- DateTime
- NegativeFloat
- NegativeInt
- NonNegativeInt
- NonZeroFloat
- NonZeroInt
- Percentage
- PositiveFloat
- PositiveInt
- AlphaNumericString
- AlphaString
- LowercaseString
- NonEmptyString
- Slug
- TrimmedString
- UppercaseString
Convention
- Every type is also created as a function of the same name.
- Every type implements
__invoke(): selfto extract the original value - Every type is strongly equal to another type of the same value (a record)
Example Usage
class User { public function __construct( public NonEmptyString $name, public PositiveInt $id, ) {} } $user = new User(NonEmptyString('Rob'), PositiveInt(123)) function getById(int $id) { /* do stuff */ } getById($user->id() /* call __invoke to get the integer value */);
Contributing
- Fork this repository.
- Add the new type to
generator.php. - Execute
generator.phpand maybe add some tests. - Update the list in this readme.
- Open a PR.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-09