StrategyChain.php in Zircon Profile 8
File
vendor/zendframework/zend-hydrator/src/Strategy/StrategyChain.php
View source
<?php
namespace Zend\Hydrator\Strategy;
use Traversable;
use Zend\Stdlib\ArrayUtils;
class StrategyChain implements StrategyInterface {
private $extractionStrategies;
private $hydrationStrategies;
public function __construct($extractionStrategies) {
$extractionStrategies = ArrayUtils::iteratorToArray($extractionStrategies);
$this->extractionStrategies = array_map(function (StrategyInterface $strategy) {
return $strategy;
}, $extractionStrategies);
$this->hydrationStrategies = array_reverse($extractionStrategies);
}
public function extract($value) {
foreach ($this->extractionStrategies as $strategy) {
$value = $strategy
->extract($value);
}
return $value;
}
public function hydrate($value) {
foreach ($this->hydrationStrategies as $strategy) {
$value = $strategy
->hydrate($value);
}
return $value;
}
}