AutoMapper – Declarative data mapper for PHP 7

综合编程 2018-01-31 阅读原文

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()

Leonid Mamchenkov

责编内容by:Leonid Mamchenkov阅读原文】。感谢您的支持!


Css and php view the fonts in the folder how to insert html, css and php in the mail function in php I am confused to use this function whe... Write to Files and Read Files With P... has continued their series of posts covering some of the basics of the PHP language with their latest arti...
Redirect all php files and the error document to i... Well this question is quite common and i also searched and tried many answeres, but i didnt get a proper format that ...
最通俗易懂的PHP反序列化原理分析 * 本文作者:你会忘了我,本文属FreeBuf原创奖励计划,未经许可禁止转载 0×01写在前面 PHP反序列化漏洞虽然利用的条件比较苛刻,但是如果可以利用一般都会产生很严重的后果。在春招的时候很多公司都问过这个问题,说明...
Php foreach in foreach looping I want to extrect all usernames and passwords each from his file and output it nicely. I wrote a code on my appserv 2.5....