承接 jamsouf/repeat 相关项目开发

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

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

jamsouf/repeat

最新稳定版本:v1.0.0

Composer 安装命令:

composer require jamsouf/repeat

包简介

Repeater utility. Work with repeated actions in a simple way.

README 文档

README

Latest Stable Version Build Status

Repeat is a repeater utility for PHP / Composer.
It makes it easy to repeat calling a function or similar operations.

Installation

Via composer

Install the latest version with composer require jamsouf/repeat

require 'vendor/autoload.php';

Examples

Call a anonymous function 100 times
$results = Repeat::_function(100, function () {
    // your function code
});
Call a named function and access in each call the current result
$calculate = function ($result) {
    // your function code
};

$results = Repeat::_function(20, $calculate);
Call a named function until a specific condition
$calculate = function ($result) {
    // your function code
};

$until = function ($result) {
    // return true or false
};

$results = Repeat::_function(50, $calculate, $until);
Repeat a string with index reference and delimiter until a specific condition
$result = Repeat::_string(10, 'v1.{j}.{i}', function ($result) {
    return strpos($result, '.4.') !== false ? true : false;
}, ', ');

// => v1.1.0, v1.2.1, v1.3.2, v1.4.3

API Documentation

Repeat::_function($count, $func, $until = null)

Repeat calling a function

  • integer $count: How often the function should be called
  • callable $func: Function to call repeated
  • callable $until (optional): Repeat calling until this function returns true
  • => return array: Results from each function call

Repeat::_string($count, $string, $until = null, $delimiter = null)

Repeat a string

  • integer $count: How often the string should be repeated
  • string $string: String to repeat
  • callable $until (optional): Repeat the string until this function returns true
  • string $delimiter (optional): Signs to separate the strings
  • => return string: Repeated string

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-08