Renames the given data array keys for the corresponding values in $mapper.
If $mapper does not have the key, the name is preserved.

@param array $mapper [from => to]
183524
public static function renameKeys(array $data, array $mapper): array
    {
        foreach ($mapper as $from => $to) {
            if (isset($data[$from])) {
                $data[$to] = $data[$from];
                unset($data[$from]);
            }
        }

        return $data;
    }
82512
public function renameRow(string $src, string $dst): bool
    {
        if (null === $this->data) {
            $this->buildIndex();
        }

        if ($this->hasKey($dst)) {
            throw new \RuntimeException("Cannot rename object: key '{$dst}' is already taken");
        }

        if (!$this->hasKey($src)) {
            return false;
        }

        // Change single key in the array without changing the order or value.
        $keys = array_keys($this->data);
        $keys[array_search($src, $keys, true)] = $dst;

        $this->data = array_combine($keys, $this->data);

        return true;
    }
8700
public function update($json, ChildrenOrderSaverMapperInterface $mapper)
    {
        $array = $this->parse($json);

        foreach ($array as $range => $value) {
            if (is_array($value)) {
                $mapper->save($value[RelationBuilder::TREE_PARAM_ID], $value[RelationBuilder::TREE_PARAM_PARENT_ID], $range);
            }
        }

        return true;
    }
871448
def rename_keys(record: Mapping, key_map: Mapping) -> dict:
    """"""

    new_record = dict()

    for k, v in record.items():
        key = key_map[k] if k in key_map else k
        new_record[key] = v

    return new_record
702104
private function useMapper(IMapper $mapper)
    {
        if ($this->mapper === null) {
            $newProperties = $this->getReflection($mapper)->getEntityProperties();
            foreach ($this->getCurrentReflection()->getEntityProperties() as $oldProperty) {
                $oldColumn = $oldProperty->getColumn();
                if ($oldColumn !== null) {
                    $name = $oldProperty->getName();
                    if (!isset($newProperties[$name]) or $newProperties[$name]->getColumn() === null) {
                        throw new InvalidStateException('Inconsistent sets of properties detected in entity ' . get_called_class() . '.');
                    }
                    if ($this->row->hasColumn($oldColumn)) {
                        $newColumn = $newProperties[$name]->getColumn();
                        $value = $this->row->$oldColumn;
                        unset($this->row->$oldColumn);
                        $this->row->$newColumn = $value;
                    }
                }
            }
            $this->mapper = $mapper;
            $this->row->setMapper($mapper);
            $this->currentReflection = null;
        } elseif ($this->mapper != $mapper) { // intentionally !=, we want to ensure that types and states are same
            throw new InvalidStateException("Given mapper isn't same as mapper already present in entity " . get_called_class() . '.');
        }
    }
317484
def rename(mapping)
      new_attributes = map do |attr|
        alias_name = mapping[attr.name]
        alias_name ? attr.aliased(alias_name) : attr
      end

      new(new_attributes)
    end
522205
protected function configureShowFields(ShowMapper $mapper)
    {
        // call to aliased trait method
        $this->configShowHandlesRelations($mapper);
        $this->configureShowDescriptions($mapper);

        //Removal of Variety/Strain specific fields
        if ($this->getSubject()) {
            if ($this->getSubject()->getIsStrain()) {
                $tabs = $mapper->getadmin()->getShowTabs();
                unset($tabs['form_tab_strains']);
                $mapper->getAdmin()->setShowTabs($tabs);
                $mapper->remove('children');
                $mapper->remove('several_strains');
            } else {
                $mapper->remove('parent');
            }
        }
    }
105
protected function unserializeEmbeddedCollection(MapperInterface $mapper, array $data)
    {
        $collection = array();
        foreach ($data as $document) {
            $collection[] = $mapper->unserialize($document);
        }

        return $collection;
    }
429334
function renameKey(obj, prevKey, nextKey) {
  return mapKeys(obj, (_, key) => (key === prevKey ? nextKey : key))
}
976288
public function setMapper($mapperClass, array $options = [])
    {
        $sl             = $this->getServiceLocator();
        $mapperManager  = $sl->get(MapperManager::class);

        $defaultOptions = [
            'model' => $this->model ?? $this->serviceAlias,
            'hydrator' => $this->hydrator ?? $this->serviceAlias,
        ];

        $options    = array_merge($defaultOptions, $options);
        $mapper     = $mapperManager->get($mapperClass, $options);

        $this->mappers[$mapperClass] = $mapper;

        return $this;
    }
981620
protected function renameResult(array &$result, $old, $new)
    {

        // Check to see if the old item is there
        if (isset($result[$old])) {
            $result[$new] = $result[$old];
            unset($result[$old]);
        }
    }
333429
public function setChildren($children, $mapper = null)
    {
        $element = clone $this;

        $element->children = new Collection();

        return $element->addChildren($children, $mapper);
    }
88163
public function renameMany(array $map) : Assoc
    {
        $pairs = array_map(function ($a, $b) {
            return [$a, $b];
        }, array_keys($map), array_values($map));

        return array_reduce($pairs, function ($that, $pair) {
            list ($from, $to) = $pair;

            return $that->rename($from, $to);
        }, $this);
    }
786116
protected function registerSoftDelete(Mapper $mapper)
    {
        $entityMap = $mapper->getEntityMap();

        // Add Scopes
        $mapper->addGlobalScope(new SoftDeletingScope());

        // Register 'deleting' events
        $mapper->registerEvent('deleting', function ($event) use ($entityMap) {
            $entity = $event->entity;
            $wrappedEntity = $this->getMappable($entity);

            $deletedAtField = $entityMap->getQualifiedDeletedAtColumn();

            if (!is_null($wrappedEntity->getEntityAttribute($deletedAtField))) {
                return true;
            }

            $time = new Carbon();

            $wrappedEntity->setEntityAttribute($deletedAtField, $time);

            $plainObject = $wrappedEntity->getObject();
            $this->manager->mapper(get_class($plainObject))->store($plainObject);

            return false;
        });

        // Register RestoreCommand
        $mapper->addCustomCommand(Restore::class);
    }
346642
function rename(object, fromKey, toKey) {
  if ((0, _has2.default)(object, fromKey)) {
    object[toKey] = object[fromKey];
    delete object[fromKey];
  }
}
410075
public function rename(string $name) {
        global $DB, $USER;

        $this->model->name = $name;
        $this->model->timemodified = time();
        $this->model->usermodified = $USER->id;

        $DB->update_record('analytics_models', $this->model);
    }
983258
protected function processMapper(CommandMapper $mapper) {
        $command = $mapper->getCommand();
        try {
            $mapper->delete();
            $command->execute();
        } catch (Exception $ex) {
            $this->erroneousMappers->push($mapper);
            Yii::getLogger()->log(
                    'An error ocurred while processing command [' . get_class($command) . '].'
                    . PHP_EOL
                    . 'Exception: [' . $ex->getTraceAsString() . ']', Logger::LEVEL_ERROR, 'command'
            );
        }
    }