综合编程

AutoMapper – Declarative data mapper for PHP 7

微信扫一扫,分享到朋友圈

AutoMapper – Declarative data mapper for PHP 7
0

AutoMapper
can map data from array/object to existing array/object or marshal a new one.

Mapping rules specified in declarative way using three simple definitions:

  • From
    definition ( From::create
    or via short function from
    ) — maps single field from source to target. Supports chainable functions:

    • ->convert(callable $callable)
      — converts input value to another one via any callable;
    • ->trim()
      — trims value to eliminate whitespaces (suitable for strings);
    • ->default($defaultValue)
      — returns default value if source field is missing;
    • ->ignoreMissing()
      — ignores target field if source field is missing;
    • ->ignoreEmpty()
      — ignores target field if source field is empty.
  • Aggregate
    definition ( Aggregate::create
    or via short function aggregate
    ) — maps multiple fields from source to single target field. Supports chainable functions:

    • ->trim()
      — trims aggregated value
    • ->ignoreEmpty()
      — ignores target field if aggregated value is empty.
  • Value
    definition ( Value::create
    or via short function value
    ) — maps constant value to target field. Supports chainable functions:

    • ->trim()
    • ->ignoreEmpty()

All missing source fields can be ignored via AutoMapper::create(...)->ignoreAllMissing()
modifier.

阅读原文...


微信扫一扫,分享到朋友圈

AutoMapper – Declarative data mapper for PHP 7
0

Leonid Mamchenkov

热点和借势追了365天,他们都记得你了吗?

上一篇

Asana raises $75 million from Al Gore’s fund, others to grow its task-management app globally

下一篇

评论已经被关闭。

插入图片

热门分类

往期推荐

AutoMapper – Declarative data mapper for PHP 7

长按储存图像,分享给朋友