示例#1
0
 /**
  * Applies callback to payload type if type is a collection
  * The callback is applied before the collection calls its own logic
  * on the current item. This allows you to prepare an item (change structure f.e.)
  * so that the collection can translate the item to its type representation
  *
  * @param Payload $payload
  * @param $callback
  * @return \Prooph\Processing\Message\Payload
  */
 public static function premap(Payload $payload, $callback)
 {
     $type = $payload->toType();
     if ($type instanceof \OuterIterator) {
         $payload->replaceType($type::fromNativeValue(new MapIterator($type->getInnerIterator(), $callback)));
     }
     return $payload;
 }