poirot / core
0.2
2016-02-29 11:30 UTC
This package is not auto-updated.
Last update: 2019-02-20 18:19:47 UTC
README
Poirot\Std 是一组组件,实现了适用于不同范围(如)的通用实用类:
- 数组实用函数;
- 待办事项
- 在 https://github.com/phPoirot/std/issues 处提交问题
- 文档在待办事项
可调用的响应者
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