You are here

protected function MapNamingStrategy::flipMapping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-hydrator/src/NamingStrategy/MapNamingStrategy.php \Zend\Hydrator\NamingStrategy\MapNamingStrategy::flipMapping()

Safelly flip mapping array.

Parameters

array $array Array to flip:

Return value

array Flipped array

Throws

InvalidArgumentException

1 call to MapNamingStrategy::flipMapping()
MapNamingStrategy::__construct in vendor/zendframework/zend-hydrator/src/NamingStrategy/MapNamingStrategy.php
Initialize.

File

vendor/zendframework/zend-hydrator/src/NamingStrategy/MapNamingStrategy.php, line 49

Class

MapNamingStrategy

Namespace

Zend\Hydrator\NamingStrategy

Code

protected function flipMapping(array $array) {
  array_walk($array, function ($value) {
    if (!is_string($value) && !is_int($value)) {
      throw new InvalidArgumentException('Mapping array can\'t be flipped because of invalid value');
    }
  });
  return array_flip($array);
}