konekod/evenly-distribute 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

konekod/evenly-distribute

最新稳定版本:1.0.0

Composer 安装命令:

composer require konekod/evenly-distribute

包简介

Universal service for even distribution of anything

README 文档

README

Universal service for even distribution of anything

Features

  • Sort by distinct by field nonUniqueEntityId

  • Distribute evenly by the values defined in pool Id.

    • (strips each element of pool id and builds an array with unique local pool id)

Usage

// See EvenlyDistributeServiceTest::testExampleWorksFine

$input = [
        ['poolId' => 'A', 'uniqueEntityId' => '123', 'nonUniqueEntityId' => 1, 'entity' => ['id' => 123]],
        ['poolId' => 'B', 'uniqueEntityId' => '456', 'nonUniqueEntityId' => 2, 'entity' => ['id' => 456]],
        ['poolId' => 'B', 'uniqueEntityId' => '678', 'nonUniqueEntityId' => 2, 'entity' => ['id' => 678]],
];

$output = EvenlyDistributeService::distributeByPools($input);

$excepted = [
    'A' => [
        ['poolId' => 'A', 'uniqueEntityId' => '123', 'nonUniqueEntityId' => 1, 'entity' => ['id' => 123]]
    ],
    'B' => [
        ['poolId' => 'B', 'uniqueEntityId' => '456', 'nonUniqueEntityId' => 2, 'entity' => ['id' => 456]]
    ],
];

echo $excepted === $output;

Testing

# Run phpunit
vendor/bin/phpunit tests

# PhpStan
composer run phpstan

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2024-06-13