UnderscoreNamingStrategy.php in Zircon Profile 8.0
File
vendor/zendframework/zend-hydrator/src/NamingStrategy/UnderscoreNamingStrategy.php
View source
<?php
namespace Zend\Hydrator\NamingStrategy;
use Zend\Filter\FilterChain;
class UnderscoreNamingStrategy implements NamingStrategyInterface {
protected static $camelCaseToUnderscoreFilter;
protected static $underscoreToStudlyCaseFilter;
public function hydrate($name) {
return $this
->getUnderscoreToStudlyCaseFilter()
->filter($name);
}
public function extract($name) {
return $this
->getCamelCaseToUnderscoreFilter()
->filter($name);
}
protected function getUnderscoreToStudlyCaseFilter() {
if (static::$underscoreToStudlyCaseFilter instanceof FilterChain) {
return static::$underscoreToStudlyCaseFilter;
}
$filter = new FilterChain();
$filter
->attachByName('WordUnderscoreToStudlyCase');
return static::$underscoreToStudlyCaseFilter = $filter;
}
protected function getCamelCaseToUnderscoreFilter() {
if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) {
return static::$camelCaseToUnderscoreFilter;
}
$filter = new FilterChain();
$filter
->attachByName('WordCamelCaseToUnderscore');
$filter
->attachByName('StringToLower');
return static::$camelCaseToUnderscoreFilter = $filter;
}
}