CompositeNamingStrategy.php in Zircon Profile 8.0
File
vendor/zendframework/zend-hydrator/src/NamingStrategy/CompositeNamingStrategy.php
View source
<?php
namespace Zend\Hydrator\NamingStrategy;
class CompositeNamingStrategy implements NamingStrategyInterface {
private $namingStrategies = [];
private $defaultNamingStrategy;
public function __construct(array $strategies, NamingStrategyInterface $defaultNamingStrategy = null) {
$this->namingStrategies = array_map(function (NamingStrategyInterface $strategy) {
return $strategy;
}, $strategies);
$this->defaultNamingStrategy = $defaultNamingStrategy ?: new IdentityNamingStrategy();
}
public function extract($name) {
$strategy = isset($this->namingStrategies[$name]) ? $this->namingStrategies[$name] : $this->defaultNamingStrategy;
return $strategy
->extract($name);
}
public function hydrate($name) {
$strategy = isset($this->namingStrategies[$name]) ? $this->namingStrategies[$name] : $this->defaultNamingStrategy;
return $strategy
->hydrate($name);
}
}