承接 phpfluent/callback 相关项目开发

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

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

phpfluent/callback

Composer 安装命令:

composer require phpfluent/callback

包简介

Allows you execute callbacks in a more dynamic way

README 文档

README

Build Status Code Quality Code Coverage Latest Version Total Downloads License

Allows you execute callbacks in a more dynamic way.

Installation

The package is available on Packagist. You can install it using Composer.

composer require phpfluent/callback

Dependencies

  • PHP 5.4+

Usage

All examples within this document assume you have the following statement at the beginning of the file:

use PHPFluent\Callback\Callback;

Define your callable

Closures

$callback = new Callback(
    function () {
        // My callable content.
    }
);

Object methods

$callback = new Callback(array($object, 'methodName'));

User defined functions

$callback = new Callback('my_function');

PHP native functions

$callback = new Callback('str_replace');

Executing your callable

There are many ways you can execute the callable.

invoke()

$callback->invoke($arg1, $arg2, $arg3);

invokeArguments()

$callback->invokeArguments($arrayArguments);

__invoke()

$callback($arg1, $arg2, $arg3); // call_user_func() and call_user_func_array() will work like a charm

Arguments

If you're reading this document you may be wondering why this library was written since everything written on it is already possible just using native PHP features.

This library provides more flexibility when defining the arguments to be used when you call your callback. That's useful when you working with callbacks in a predefined structure but you don't want all arguments.

Names

Callback will execute your callback based on its parameters name.

$callable = new Callback(
    function ($foo, $bar = true) {
        // My callable body
    }
);
$callable->invokeArguments(
    array(
        'foo' => 'PHPFluent',
    )
);

Types

Doesn't matter the order of the arguments, Callback will put it in the right order before execute your callable.

$callable = new Callback(
    function (array $array, TypeTwo $typeTwo, $string, $int, TypeThree $typeThree, $optional = 42) {
        // My callable body
    }
);
$callable(array(), new TypeTwo(), new TypeThree(), 'string', 123);

统计信息

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

GitHub 信息

  • Stars: 11
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固