承接 jeroen/rewindable-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jeroen/rewindable-generator

最新稳定版本:1.2.0

Composer 安装命令:

composer require jeroen/rewindable-generator

包简介

Provides a simple adapter to make generators rewindable

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Download count

Provides a simple adapter to make generators rewindable. Please beware that you can do the same by using PHPs native CachingIterator.

Unfortunately, you cannot do this:

$generator = $myGeneratorFunction();
iterator_to_array($generator);
iterator_to_array($generator); // boom!

Or this:

$generator = $myGeneratorFunction();
$generator->next();
$generator->rewind(); // boom!

Both result in an Exception, as proven by the tests in tests/GeneratorTest.php. This library provides a simple class that takes a generator function (the function, not its return value) and adapts it to a rewindable Iterator.

$generator = new RewindableGenerator($myGeneratorFunction);
iterator_to_array($generator);
iterator_to_array($generator); // works as expected
$generator->rewind(); // works as expected

Installation

To add this package as a local, per-project dependency to your project, simply add a dependency on jeroen/rewindable-generator to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a dependency on Rewindable Generator 1.x:

{
    "require": {
        "jeroen/rewindable-generator": "~1.0"
    }
}

Running the tests

For tests only

composer test

For style checks only

composer cs

For a full CI run

composer ci

Release notes

Version 1.2.0 (2017-05-16)

  • Dropped PHP 5.x support

Version 1.1.1 (2015-11-08)

Version 1.1.0 (2015-11-08)

  • Added onRewind function and second constructor parameter to RewindableGenerator

Version 1.0.0 (2015-11-08)

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-11-08