reload/cpr
Composer 安装命令:
composer require reload/cpr
包简介
CPR: Danish personal identification numbers
README 文档
README
A class representing Danish civil registration numbers (CPR numbers).
The CPR number is a ten digit number with the format DDMMYY-SSSS, where the first six digits represent the date of birth and the last four digits are a sequence number.
The CPR number is used in Denmark to uniquely identify persons in various systems, and is also used as a personal identification number in many contexts.
The class represents a CPR number as a read-only value object, and provides methods for working with, formatting, and validating CPR numbers.
- Full name:
\Reload\Cpr\CprNumber
Methods
__construct
Construct a CPR number readonly value object from a string.
public __construct(string $cpr)
Parameters:
| Parameter | Type | Description |
|---|---|---|
$cpr |
string | A string with the CPR number. |
Throws:
If the CPR number does not contain 10 digits
InvalidCprNumberFormatIf the date in the CPR number doesn't exist.NonExistingDate
__toString
Format the CPR number in the traditional format (120345-6789).
public __toString(): string
See Also:
- \Reload\Cpr\CprNumber::formatPretty()
formatPretty
Format the CPR number in the traditional format (120345-6789).
public formatPretty(): string
formatNumbersOnly
Format the CPR number using numbers only (1203456789).
public formatNumbersOnly(): string
isFemale
Check if the CPR number represents a female person.
public isFemale(): bool
isMale
Check if the CPR number represents a male person.
public isMale(): bool
getDateTimeImmutable
Get a DateTimeImmutable object from the CPR number.
public getDateTimeImmutable(?\DateTimeZone $timezone = null): ?\DateTimeImmutable
Parameters:
| Parameter | Type | Description |
|---|---|---|
$timezone |
?\DateTimeZone | A DateTimeZone object for the desired time zone. Defaults: current timezone. |
validateModulus11
Validate the CPR number using the modulus 11 algorithm.
public validateModulus11(): bool
NOTICE: CPR numbers are no longer required to fulfill the modulus 11 check. You should NOT use this method to validate or dismiss CPR numbers.
reload/cpr 适用场景与选型建议
reload/cpr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 422 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 reload/cpr 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reload/cpr 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 422
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-06