pew-pew/hydrator

对象水化器内核库

0.1.0 2024-03-17 11:39 UTC

This package is auto-updated.

Last update: 2024-08-23 12:10:34 UTC


README

PHP 8.3+ Latest Stable Version Latest Unstable Version License MIT

水化器

一组接口,用于将任意值映射到它们的类型等效值及其逆。

安装

PewPew 水化器作为 Composer 仓库提供,您可以使用以下命令在项目根目录中安装:

$ composer require pew-pew/hydrator

更详细的安装说明请参阅此处

使用方法

$hydrator = new class implements \PewPew\Hydrator\HydratorInterface {
    public function hydrate(string $type, mixed $data): mixed
    {
         return ...;
    }
};

$hydrator = new \PewPew\Hydrator\TraceableHydrator(
    hydrator: $hydrator,
    stopwatch: new \Symfony\Component\Stopwatch\Stopwatch(),
);

$hydrator = new \PewPew\Hydrator\LoggableHydrator(
    hydrator: $hydrator,
    logger: new ExampleLogger(),
);