-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul
committed
Feb 1, 2017
1 parent
fa9d018
commit 7051ba4
Showing
1 changed file
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
<?php | ||
namespace ScriptFUSION\Mapper\Strategy; | ||
|
||
use ScriptFUSION\Mapper\MapperAware; | ||
use ScriptFUSION\Mapper\MapperAwareTrait; | ||
use ScriptFUSION\Mapper\Mapping; | ||
|
||
/** | ||
* Walks a nested structure to the specified element in the same manner as Copy. | ||
*/ | ||
class Walk extends Copy implements MapperAware | ||
class Walk extends Delegate | ||
{ | ||
use MapperAwareTrait; | ||
|
||
private $expression; | ||
/** | ||
* @var Copy | ||
*/ | ||
private $copy; | ||
|
||
/** | ||
* @param Strategy|Mapping|array|mixed $expression Expression. | ||
* @param array|string $path Array of path components or string of `->`-delimited components. | ||
*/ | ||
public function __construct($expression, $path) | ||
{ | ||
parent::__construct($path); | ||
parent::__construct($expression); | ||
|
||
$this->expression = $expression; | ||
$this->copy = new Copy($path); | ||
} | ||
|
||
public function __invoke($data, $context = null) | ||
{ | ||
return parent::__invoke($this->getMapper()->map($data, $this->expression, $context), $context); | ||
return call_user_func($this->copy, parent::__invoke($data, $context), $context); | ||
} | ||
} |