src/collections/Variables.php
public function mapKeys(array $replaces, $strict = true)
    {
        $mapped = [];
        foreach ($this->value as $key => $value) {
            if (isset($replaces[$key])) {
                $newKey = $replaces[$key];
            } elseif ($strict) {
                throw new UnexpectedKeyException('Key "' . $key . '" not found in map.');
            } else {
                $newKey = $key;
            }
            
            $mapped[$newKey] = $value;
        }
        
        $this->value = $mapped;
        
        return $this;
    }
public function mapKeys(array $replaces, $strict = true)
    {
        $mapped = [];
        foreach ($this->value as $key => $value) {
            if (isset($replaces[$key])) {
                $newKey = $replaces[$key];
            } elseif ($strict) {
                throw new UnexpectedKeyException('Key "' . $key . '" not found in map.');
            } else {
                $newKey = $key;
            }
            
            $mapped[$newKey] = $value;
        }
        
        $this->value = $mapped;
        
        return $this;
    }
public function mapKeys ( array $ replaces , $ strict = true ) { $ mapped = [ ] ; foreach ( $ this -> value as $ key => $ value ) { if ( isset ( $ replaces [ $ key ] ) ) { $ newKey = $ replaces [ $ key ] ; } elseif ( $ strict ) { throw new UnexpectedKeyException ( 'Key "' . $ key . '" not found in map.' ) ; } else { $ newKey = $ key ; } $ mapped [ $ newKey ] = $ value ; } $ this -> value = $ mapped ; return $ this ; }
Replaces collection keys using map array.
@param array $replaces old keys to new keys map.
@param boolean $strict whether to throw exception when key is not in the map.
@return $this
@throws UnexpectedKeyException if strict and key is not in the map.
Replaces collection keys using map array .