You are here

class ArrayMapNamingStrategy in Zircon Profile 8

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

Hierarchy

Expanded class hierarchy of ArrayMapNamingStrategy

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

File

vendor/zendframework/zend-hydrator/src/NamingStrategy/ArrayMapNamingStrategy.php, line 12

Namespace

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

  /**
   * @var string[]
   */
  private $extractionMap = [];

  /**
   * @var string[]
   */
  private $hydrationMap = [];

  /**
   * Constructor
   *
   * @param array $extractionMap A map of string keys and values for symmetric translation of hydrated
   *                             and extracted field names
   */
  public function __construct(array $extractionMap) {
    $this->extractionMap = $extractionMap;
    $this->hydrationMap = array_flip($extractionMap);
  }

  /**
   * {@inheritDoc}
   */
  public function hydrate($name) {
    return isset($this->hydrationMap[$name]) ? $this->hydrationMap[$name] : $name;
  }

  /**
   * {@inheritDoc}
   */
  public function extract($name) {
    return isset($this->extractionMap[$name]) ? $this->extractionMap[$name] : $name;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ArrayMapNamingStrategy::$extractionMap private property
ArrayMapNamingStrategy::$hydrationMap private property
ArrayMapNamingStrategy::extract public function Converts the given name so that it can be hydrated by the hydrator. Overrides NamingStrategyInterface::extract
ArrayMapNamingStrategy::hydrate public function Converts the given name so that it can be extracted by the hydrator. Overrides NamingStrategyInterface::hydrate
ArrayMapNamingStrategy::__construct public function Constructor