class CompositeNamingStrategy in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-hydrator/src/NamingStrategy/CompositeNamingStrategy.php \Zend\Hydrator\NamingStrategy\CompositeNamingStrategy
- 8 vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/CompositeNamingStrategy.php \Zend\Stdlib\Hydrator\NamingStrategy\CompositeNamingStrategy
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-hydrator/src/NamingStrategy/CompositeNamingStrategy.php \Zend\Hydrator\NamingStrategy\CompositeNamingStrategy
Hierarchy
- class \Zend\Hydrator\NamingStrategy\CompositeNamingStrategy implements NamingStrategyInterface
Expanded class hierarchy of CompositeNamingStrategy
1 file declares its use of CompositeNamingStrategy
- CompositeNamingStrategy.php in vendor/
zendframework/ zend-stdlib/ src/ Hydrator/ NamingStrategy/ CompositeNamingStrategy.php
File
- vendor/
zendframework/ zend-hydrator/ src/ NamingStrategy/ CompositeNamingStrategy.php, line 12
Namespace
Zend\Hydrator\NamingStrategyView source
class CompositeNamingStrategy implements NamingStrategyInterface {
/**
* @var array
*/
private $namingStrategies = [];
/**
* @var NamingStrategyInterface
*/
private $defaultNamingStrategy;
/**
* @param NamingStrategyInterface[] $strategies indexed by the name they translate
* @param NamingStrategyInterface|null $defaultNamingStrategy
*/
public function __construct(array $strategies, NamingStrategyInterface $defaultNamingStrategy = null) {
$this->namingStrategies = array_map(function (NamingStrategyInterface $strategy) {
// this callback is here only to ensure type-safety
return $strategy;
}, $strategies);
$this->defaultNamingStrategy = $defaultNamingStrategy ?: new IdentityNamingStrategy();
}
/**
* {@inheritDoc}
*/
public function extract($name) {
$strategy = isset($this->namingStrategies[$name]) ? $this->namingStrategies[$name] : $this->defaultNamingStrategy;
return $strategy
->extract($name);
}
/**
* {@inheritDoc}
*/
public function hydrate($name) {
$strategy = isset($this->namingStrategies[$name]) ? $this->namingStrategies[$name] : $this->defaultNamingStrategy;
return $strategy
->hydrate($name);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CompositeNamingStrategy:: |
private | property | ||
CompositeNamingStrategy:: |
private | property | ||
CompositeNamingStrategy:: |
public | function |
Converts the given name so that it can be hydrated by the hydrator. Overrides NamingStrategyInterface:: |
|
CompositeNamingStrategy:: |
public | function |
Converts the given name so that it can be extracted by the hydrator. Overrides NamingStrategyInterface:: |
|
CompositeNamingStrategy:: |
public | function |