定制 freyr/identity 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

freyr/identity

最新稳定版本:v1.0.1

Composer 安装命令:

composer require freyr/identity

包简介

A PHP library for Identity concept.

README 文档

README

Monotonic ULID identity objects for PHP domain models. Provides an immutable Id value object and an IdCollection for working with sets of identifiers.

Installation

composer require freyr/identity

Requires PHP 8.2+.

Usage

Id

Create, convert and compare identifiers.

use Freyr\Identity\Id;

$id = Id::new();
$id = Id::fromString('01ARYZ6S41TSV4RRFFQ69G5FAV');
$id = Id::fromBinary($bytes);

(string) $id;    // ULID string (26 chars, Crockford Base32)
$id->toBinary(); // 16-byte binary
$id->sameAs($other);

Extend for typed identifiers.

class UserId extends Id {}

$userId = UserId::new();

IdCollection

Immutable collection with standard operations.

use Freyr\Identity\IdCollection;

$collection = IdCollection::fromArray([$id1, $id2]);
$collection = IdCollection::empty();

$collection->add($id);
$collection->remove($id);
$collection->contains($id);
$collection->merge($other);
$collection->intersect($other);
$collection->filter(fn (Id $id) => /* ... */);
$collection->map(fn (Id $id) => /* ... */);

$collection->first();
$collection->last();
$collection->count();
$collection->isEmpty();
$collection->toArray();
$collection->toStringArray();
$collection->toBinaryArray();

All mutating methods return new instances.

Licence

MIT

统计信息

  • 总下载量: 1.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固