紧凑/集合运行器

此包最新版本(1.1.0)没有可用的许可信息。

一个小助手,可以在事件发射过程中运行一系列事物。

1.1.0 2019-03-24 11:14 UTC

This package is auto-updated.

Last update: 2024-09-07 03:13:33 UTC


README

一个小助手,可以在事件发射过程中运行一系列事物。

安装

通过Composer

  • composer require kompakt/collection-runner

示例

以5个项目的部分(页面)遍历列表

use Kompakt\CollectionRunner\Console\Subscriber\Debugger;
use Kompakt\CollectionRunner\Runner;
use Kompakt\CollectionRunner\EventNames;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\EventDispatcher\EventDispatcher;

$dispatcher = new EventDispatcher();
$eventNames = new EventNames();
$runner = new Runner($dispatcher, $eventNames);
$debugger = new Debugger($dispatcher, $eventNames);
$debugger->activate(new ConsoleOutput());

$countries = [
    'Andorra',
    'Austria',
    'Australia',
    'Brazil',
    'Chile',
    'Cuba',
    'Germany',
    'Finland',
    'France',
    'Guatemala',
    'Italy',
    'Lebanon',
    'Morocco',
    'Nepal',
    'Russia',
    'Switzerland',
    'Thailand'
];

$getCountriesCallable = function($first, $max) use ($countries)
{
    return array_slice($countries, $first, $max);
};

$runner->run(count($countries), $getCountriesCallable, 5);

许可

kompakt/collection-runner遵循MIT许可协议 - 详细信息请参阅LICENSE文件