sminnee/callbacklist 问题修复 & 功能扩展

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

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

sminnee/callbacklist

最新稳定版本:0.1.1

Composer 安装命令:

composer require sminnee/callbacklist

包简介

PHP class that manages a list of callbacks

README 文档

README

Build Status Scrutinizer Code Quality codecov.io

Latest Stable Version License Monthly Downloads

GitHub Code Size GitHub Last Commit GitHub Activity GitHub Issues

This micropackage provides a simple class for managing a list of callbacks.

Usage

> composer require sminnee/callbacklist
use Sminnee\CallbackList\CallbackList;

$list = new CallbackList;
$list->add(function() { "this will get called"; });
$list->add(function() { "so will this"; });
$list->call();

// Or you can use it as a callable if you prefer
$list();

Arguments can be passed:

$list->add(function($greeting) { "$greeting, world!"; });
$list("Hello");

Return values are collated as an array

use Sminnee\CallbackList\CallbackList;

$list = new CallbackList;
$list->add(function() { return "this will get returned"; });
$list->add(function() { return "so will this"; });

// ["this will get returned", "so will this"]
var_dump($list());

Existing callbacks can be manipulated:

// Clear the list
$list->clear();

// Or add a callback with a name
$list->add(function($greeting) { "$greeting, world!"; }, 'greeter');

// And then remove by that name
$list->remove('greeter');

And you can inspect the content of the list:

// Return a single named callback
$list->get('greeter');

// Return everything as an array
$list->getAll();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-28