poirot/core

该包已被弃用,不再维护。作者建议使用 poirot/std 包。
该包最新版本(0.2)没有可用的许可信息。

Poirot 标准库和基础功能。

0.2 2016-02-29 11:30 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:19:47 UTC


README

Build Status

Poirot\Std 是一组组件,实现了适用于不同范围(如)的通用实用类:

  • 数组实用函数;
  • 待办事项

可调用的响应者

class SayHi
{
    function __construct($name, $family)
    {
        $this->name = $name;
        $this->family = $family;
    }

    function __toString()
    {
        return sprintf('Hello %s %s.', $this->name, $this->family);
    }
}

$inv1 = function () {
    return ['name' => 'Payam'];
};

$inv2 = function ($name, $family) {
    return new SayHi($name, $family);
};


$invokable = new InvokableResponder(function() {
    return ['family' => 'Naderi'];
});

$invokable = $invokable
    ->thenWith($inv1)

    ->thenWith($inv2)

    ->thenWith(function (SayHi $message) {
        return (string) $message;
    })->setIdentifier('hello')
;

$r = $invokable(['family' => 'Payami'])['hello'];
// Hello Payam Payami