You are here

class UnderscoreNamingStrategy in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-hydrator/src/NamingStrategy/UnderscoreNamingStrategy.php \Zend\Hydrator\NamingStrategy\UnderscoreNamingStrategy
  2. 8.0 vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php \Zend\Stdlib\Hydrator\NamingStrategy\UnderscoreNamingStrategy
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-hydrator/src/NamingStrategy/UnderscoreNamingStrategy.php \Zend\Hydrator\NamingStrategy\UnderscoreNamingStrategy

Hierarchy

Expanded class hierarchy of UnderscoreNamingStrategy

1 file declares its use of UnderscoreNamingStrategy
UnderscoreNamingStrategy.php in vendor/zendframework/zend-stdlib/src/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php

File

vendor/zendframework/zend-hydrator/src/NamingStrategy/UnderscoreNamingStrategy.php, line 14

Namespace

Zend\Hydrator\NamingStrategy
View source
class UnderscoreNamingStrategy implements NamingStrategyInterface {

  /**
   * @var FilterChain|null
   */
  protected static $camelCaseToUnderscoreFilter;

  /**
   * @var FilterChain|null
   */
  protected static $underscoreToStudlyCaseFilter;

  /**
   * Remove underscores and capitalize letters
   *
   * @param  string $name
   * @return string
   */
  public function hydrate($name) {
    return $this
      ->getUnderscoreToStudlyCaseFilter()
      ->filter($name);
  }

  /**
   * Remove capitalized letters and prepend underscores.
   *
   * @param  string $name
   * @return string
   */
  public function extract($name) {
    return $this
      ->getCamelCaseToUnderscoreFilter()
      ->filter($name);
  }

  /**
   * @return FilterChain
   */
  protected function getUnderscoreToStudlyCaseFilter() {
    if (static::$underscoreToStudlyCaseFilter instanceof FilterChain) {
      return static::$underscoreToStudlyCaseFilter;
    }
    $filter = new FilterChain();
    $filter
      ->attachByName('WordUnderscoreToStudlyCase');
    return static::$underscoreToStudlyCaseFilter = $filter;
  }

  /**
   * @return FilterChain
   */
  protected function getCamelCaseToUnderscoreFilter() {
    if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) {
      return static::$camelCaseToUnderscoreFilter;
    }
    $filter = new FilterChain();
    $filter
      ->attachByName('WordCamelCaseToUnderscore');
    $filter
      ->attachByName('StringToLower');
    return static::$camelCaseToUnderscoreFilter = $filter;
  }

}

Members