@@ -317,17 +317,17 @@ The following strategies ship with Mapper and provide a suite of commonly used f
317317
318318### Copy
319319
320- Copy copies a portion of the input data with support for nested structures .
320+ Copies a portion of the input data according to the specified path. Supports traversing nested arrays .
321321
322- Copy is probably the most common strategy whether used by itself or injected into other strategies.
322+ ` Copy ` is probably the most common strategy whether used by itself or injected into other strategies.
323323
324324#### Signature
325325
326326``` php
327- Copy(array|string $path)
327+ Copy(Strategy|Mapping| array|mixed $path)
328328```
329329
330- 1 . ` $path ` &ndash ; Array of path components or string of ` -> ` -delimited components.
330+ 1 . ` $path ` &ndash ; Array of path components, string of ` -> ` -delimited path components or a strategy or mapping resolving to such an expression .
331331
332332#### Example
333333
@@ -351,17 +351,35 @@ $data = [
351351
352352> 123
353353
354+ #### Path resolver example
355+
356+ Since the path can be derived from other strategies we could nest ` Copy ` instances to look up values referenced by other keys.
357+
358+ ``` php
359+ (new Mapper)->map(
360+ [
361+ 'foo' => 'bar',
362+ 'bar' => 'baz',
363+ 'baz' => 'qux',
364+ ],
365+ new Copy(new Copy(new Copy('foo')))
366+ );
367+ ```
368+
369+ > 'qux'
370+
354371### CopyContext
355372
356373Copies a portion of context data; works exactly the same way as ` Copy ` in all other respects.
357374
358375#### Signature
359376
360377``` php
361- CopyContext(array|string $path)
378+ CopyContext(Strategy|Mapping| array|mixed $path)
362379```
363380
364- 1 . ` $path ` &ndash ; Array of path components or string of ` -> ` -delimited components.
381+ 1 . ` $path ` &ndash ; Array of path components, string of ` -> ` -delimited path components or a strategy or mapping resolving to such an expression.
382+
365383
366384#### Example
367385
@@ -871,11 +889,11 @@ Walks a nested structure to the specified element in the same manner as [`Copy`]
871889#### Signature
872890
873891``` php
874- Walk(Strategy|Mapping|array|mixed $expression, array|string $path)
892+ Walk(Strategy|Mapping|array|mixed $expression, Strategy|Mapping| array|mixed $path)
875893```
876894
877- 1 . ` $expression ` &ndash ; Expression.
878- 2 . ` $path ` Array of path components or string of ` -> ` -delimited components.
895+ 1 . ` $expression ` &ndash ; Expression to walk .
896+ 2 . ` $path ` & ndash ; Array of path components, string of ` -> ` -delimited path components or a strategy or mapping resolving to such an expression .
879897
880898#### Example
881899
0 commit comments