catalyst/servant

Catalyst Servant 依赖抑制库

v0.1.1 2017-01-27 02:33 UTC

This package is not auto-updated.

Last update: 2024-09-29 01:29:13 UTC


README

Catalyst Servant - 依赖抑制库

什么是 Servant ?

Servant 是基于责任链的依赖抑制器。Servant 提供根据类名或 ReflectionParameter 实例解决给定依赖的能力。

用法

use Catalyst\Servant\{
    RepositoryServant,
    BlindServant
};

$servant = new RepositoryServant();
$servant->chain(new BlindServant());
$servant->ensure(DateTimeInterface::class, function() {
    return date_create();
});

$dateTime = $servant->resolve(DateTimeInterface::class);

包装的 Servant

此包提供以下 ServantInterface 实现支持:

  • RepositoryServant - 基于存储库的仆人,允许为具体实例分配别名和接口。
  • BlindServant - 一个盲仆人,允许随意实例化对象。
  • NullServant - 一个空仆人,返回 null 并作为无依赖解算器成功时的终点。

许可证和维护者

此软件包采用 MIT 许可证。此软件包由

  • Matthias Kaschubowski