my-gov/myssm
Composer 安装命令:
composer require my-gov/myssm
包简介
A parser and validate Malaysian business registration numbers (BRN). This library ensures compliance with SSM formatting standards, accurately extracts components such as entity type and registration year, and verifies the integrity of BRNs.
README 文档
README
A simple MySSM business registration number and validator.
Install
composer require my-gov/myssm
Basic Usage
Use MySSM BRN parser to retrieve basic information from a given business registration number.
require 'vendor/autoload.php'; use MyGOV\MySSM\BRN; use MyGOV\MySSM\Exceptions\ParseBRNException; use MyGOV\MySSM\Exceptions\InvalidBRNException; use MyGOV\MySSM\Exceptions\InvalidBRNFormatException; use MyGOV\MySSM\Format\Enums\EntityCode; use Throwable; try { $brn = BRN::parse('201901000005 (1312525-A)'); if ($brn->isValid()) { echo $brn; // 201901000005 (1312525-A) echo $brn->format2019; // 201901000005 echo $brn->format2019->isValid(); // true echo $brn->format2019->getYear(); // 2019 echo $brn->format2019->getEntityCode(); // 01 echo $brn->format2019->getEntityTypeName(); // Local Companies echo $brn->format2019->getSequenceNumber(); // 000005 echo $brn->format2019->is(EntityCode::Business);// false echo $brn->classic; // 1312525-A echo $brn->classic->isValid(); // true echo $brn->classic->getSequenceNumber(); // 1312525 echo $brn->classic->getCheckDigit(); // A echo $brn->classic->is(EntityCode::Business); // false } $brn = BRN::parse('SA0173178-P/ 202003000005'); if ($brn->isValid()) { echo $brn; // 202003000005 (SA0173178-P) echo $brn->format2019; // 202003000005 echo $brn->format2019->isValid(); // true echo $brn->format2019->getYear(); // 2020 echo $brn->format2019->getEntityCode(); // 03 echo $brn->format2019->getEntityTypeName(); // Business (ROB) echo $brn->format2019->getSequenceNumber(); // 000005 echo $brn->format2019->is(EntityCode::Business);// true echo $brn->classic; // SA0173178-P echo $brn->classic->isValid(); // true echo $brn->classic->getSequenceNumber(); // SA0173178 echo $brn->classic->getCheckDigit(); // P echo $brn->classic->is(EntityCode::Business); // true } $brn = BRN::parse('SA0173178-P'); if ($brn->isValid()) { echo $brn; // SA0173178-P echo $brn->format2019; // null echo $brn->format2019->isValid(); // false echo $brn->format2019->getYear(); // null echo $brn->format2019->getEntityCode(); // null echo $brn->format2019->getEntityTypeName(); // null echo $brn->format2019->getSequenceNumber(); // null echo $brn->format2019->is(EntityCode::Business);// false echo $brn->classic; // SA0173178-P echo $brn->classic->isValid(); // true echo $brn->classic->getSequenceNumber(); // SA0173178 echo $brn->classic->getCheckDigit(); // P echo $brn->classic->is(EntityCode::Business); // true } $brn = BRN::parse('3178-Q'); if ($brn->isValid()) { echo $brn; // 0003178-Q echo $brn->format2019; // null echo $brn->format2019->isValid(); // false echo $brn->format2019->getYear(); // null echo $brn->format2019->getEntityCode(); // null echo $brn->format2019->getEntityTypeName(); // null echo $brn->format2019->getSequenceNumber(); // null echo $brn->format2019->is(EntityCode::Business); // false echo $brn->classic; // 3178-P echo $brn->classic->isValid(); // true echo $brn->classic->leadingZeros(); // 0003178-P echo $brn->classic->getSequenceNumber(); // 3178 echo $brn->classic->leadingZeros()->getSequenceNumber(); // 0003178 show leading zeros. echo $brn->classic->getCheckDigit(); // P echo $brn->classic->is(EntityCode::Business); // false } } catch (Throwable $throwable) { echo $throwable->getMessage(); }
Turn On the Exceptions
Set exception to true for enable Exceptions
require 'vendor/autoload.php'; use MyGOV\MySSM\BRN; try { $brn = BRN::parse('201901003209 (000184266S)', exception: true); if ($brn->isValid()) { echo $brn->classic->getSequenceNumber(); // 000184266 echo $brn->classic->getCheckDigit(); // S } else { echo $brn->classic->getSequenceNumber(); // null echo $brn->classic->getCheckDigit(); // null } } catch (ParseBRNException | InvalidBRNException | InvalidBRNFormatException | Throwable $throwable) { echo $throwable->getMessage(); }
Business Registration Number (BRN) Generator
Generate a random business registration number.
require 'vendor/autoload.php'; use MyGOV\MySSM\Exceptions\GenerateBRNException; use MyGOV\MySSM\Format\Enums\EntityCode; use MyGOV\MySSM\BRN; try { $brn = BRN::make(); if ($brn->isValid()) { echo $brn; // 202003000005 (SA0173178-P) echo $brn->format2019; // 202003000005 echo $brn->format2019->isValid(); // true echo $brn->format2019->getYear(); // 2020 echo $brn->format2019->getEntityCode(); // 03 echo $brn->format2019->getEntityTypeName(); // Business (ROB) echo $brn->format2019->getSequenceNumber(); // 000005 echo $brn->format2019->is(EntityCode::Business);// true echo $brn->classic; // SA0173178-P echo $brn->classic->isValid(); // true echo $brn->classic->getSequenceNumber(); // SA0173178 echo $brn->classic->getCheckDigit(); // P echo $brn->classic->is(EntityCode::Business); // true } } catch(GenerateBRNException | Throwable Throwable) { echo $throwable->getMessage(); }
Generate a BRN with year of registration.
$brn = BRN::make(year: 2010); if ($brn->isValid()) { echo $brn; // 201001000005 (SA0173178-P) echo $brn->format2019; // 201001000005 echo $brn->format2019->isValid(); // true echo $brn->format2019->getYear(); // 2010 echo $brn->format2019->getEntityCode(); // 01 echo $brn->format2019->getEntityTypeName(); // Local Companies echo $brn->format2019->getSequenceNumber(); // 000005 echo $brn->format2019->is(EntityCode::Business);// false echo $brn->classic; // SA0173178-P echo $brn->classic->isValid(); // true echo $brn->classic->getSequenceNumber(); // SA0173178 echo $brn->classic->getCheckDigit(); // P echo $brn->classic->is(EntityCode::Business); // false }
Generate a ROB BRN.
$brn = BRN::make(entityCode: EntityCode::Business); if ($brn->isValid()) { echo $brn; // 199003000005 (SA0173178-P) echo $brn->format2019; // 199003000005 echo $brn->format2019->isValid(); // true echo $brn->format2019->getYear(); // 1990 echo $brn->format2019->getEntityCode(); // 03 echo $brn->format2019->getEntityTypeName(); // Business (ROB) echo $brn->format2019->getSequenceNumber(); // 000005 echo $brn->format2019->is(EntityCode::Business);// true echo $brn->classic; // SA0173178-P echo $brn->classic->isValid(); // true echo $brn->classic->getSequenceNumber(); // SA0173178 echo $brn->classic->getCheckDigit(); // P echo $brn->classic->is(EntityCode::Business); // true }
License
The Simsoft MyGOV/MySSM is licensed under the MIT License. See the LICENSE file for details
my-gov/myssm 适用场景与选型建议
my-gov/myssm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 170 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「myssm」 「suruhanjaya syarikat malaysia」 「business registration number」 「brn」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 my-gov/myssm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 my-gov/myssm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 170
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-28