bloise/flunt-php
Composer 安装命令:
composer require bloise/flunt-php
包简介
Library for notifications and validations
README 文档
README
PHP implementation of Domain Notification Pattern based in Flunt (.NET) developed by @andrebaltieri
Flunt
Flunt is a fluent way to use Notification Pattern with your entities, concentrating every change you made and easy accessing it when you need.
check our Wiki for more details and samples of how to use Flunt in your applications.
Dependencies
| Package | Version |
|---|---|
PHP |
>=8.1 |
Instalation
This package is available through Packagist
Composer
composer require bloise/flunt
How to use
final class CPF extends Notifiable { ... } $cpf = new CPF('012.345.678-90'); $cpf->addNotification("CPF", "Invalid document"); if($cpf->isValid()) ...
Specified contract
final class CPF extends Notifiable { private readonly string $document; public function __construct(string $document) { $this->setDocument($document); $this->addNotifications( (new CPFContract) ->hasMinLen($this->document, 'CPF', 'Invalid length') ->validFormat($this->document, 'CPF', 'Invalid format') ->validDocument($this->document, 'CPF', 'Invalid document') ); } } final class CPFContract extends Contract { public function hasMinLen(string $cpf, string $property, string $message): self { if (strlen($cpf) != 11) { $this->notifications[$property][] = $message; } } public function validFormat(string $cpf, string $property, string $message): self {...} public function validDocument(string $cpf, string $property, string $message): self {...} }
Fluent Methods
$cpf->isValid(); $cpf->getMessages(); $cpf->filterByMessage('Invalid length');
Designed for modern architectures approaches
If you are building an application with clean architecture approaches you can consider use this project, cause it's totally free of external dependencies, feel free to implement a Port/Adapter linking the dependencie with your code base, this one is for those who are more conceptual =)
bloise/flunt-php 适用场景与选型建议
bloise/flunt-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 10, 最近一次更新时间为 2022 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bloise/flunt-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bloise/flunt-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-28