Transforms choice keys into entities.

@param mixed $array An array of entities

@return Collection A collection of entities

@throws TransformationFailedException
965496
public function reverseTransform($array)
    {
        if ('' === $array || null === $array) {
            $array = [];
        }

        $values = [];
        foreach ($array as $fieldId => $fieldValue) {
            if ($fieldValue === null) {
                continue;
            }
            if (!$fieldValue instanceof FieldValueInterface) {
                throw new TransformationFailedException('Expected a ' . FieldValueInterface::class . ' object.');
            }
            if (!$fieldValue->getField()) {
                $field = $this->contentManager->getFieldById($this->contentType, $fieldId);
                if ($field === null) {
                    continue;
                }
                $fieldValue->setField($field);
            }
            $values[] = $fieldValue;
        }

        return new ArrayCollection($values);
    }
981995
protected function doCreateObject(array $array)
    {
        $attribute = new Attribute(isset($array['attributes']) && is_array($array['attributes']) ? $array['attributes'] : $array);
        if (isset($array['attributeValues'])) {
            $mapper = new AttributeValuesMapper();
            foreach ($array['attributeValues'] as $item) {
                $attribute->values[] = $mapper->createObject($item);
            }
        }

        if (isset($array['attributeGroups'])) {
            $mapper           = new AttributeGroupsMapper();
            $attribute->group = $mapper->createObject($array['attributeGroups']);
        }


        return $attribute;
    }
696609
public function translateArray(array $array)
    {
        $result = array();

        foreach ($array as $key => $value) {
            // Group translation
            if (is_array($value)) {
                $key = $this->translate($key);

                // If group is not created yet, create it
                if (!isset($result[$key])){
                    $result[$key] = array();
                }

                foreach($value as $index => $inner) {
                    $result[$key][$index] = $this->translate($inner);
                }
                
            } else if (is_scalar($value)) {
                $result[$key] = $this->translate($value);
            } else {
                throw new InvalidArgumentException('Invalid array supplied');
            }
        }

        return $result;
    }
477588
public function recursiveConvertInArray($array)
    {
        $newArray = [];
        foreach ($array as $key => $value) {
            if ($value instanceof \MongoDB\Model\BSONDocument || $value instanceof \MongoDB\Model\BSONArray) {
                $value = (array) $value;
            }

            if (is_array($value)) {
                $value = $this->recursiveConvertInArray($value);
            }

            $newArray[$key] = $value;
        }

        return $newArray;
    }
76968
public static function expandFromDotNotatedKeys(array $array) {
    $data = new Data();

    // @todo Make this work at all levels of array.
    foreach ($array as $key => $value) {
      $data->set($key, $value);
    }

    return $data->export();
  }
1252232
public function reverseTransform($array)
    {
        $ret = new ArrayCollection();

        foreach ($array as $el) {
            $ret->add(
                $this->em
                    ->getRepository($this->class)
                    ->find($el)
            );
        }
        return $ret;
    }
926307
protected function mapTypes($array) {
    foreach ($array as $key => $val) {
      $this->$key = $val;

      $keyTypeName = "__$key" . 'Type';
      $keyDataType = "__$key" . 'DataType';
      if ($this->useObjects() && property_exists($this, $keyTypeName)) {
        if ($this->isAssociativeArray($val)) {
          if (isset($this->$keyDataType) && 'map' == $this->$keyDataType) {
            foreach($val as $arrayKey => $arrayItem) {
              $val[$arrayKey] = $this->createObjectFromName($keyTypeName, $arrayItem);
            }
            $this->$key = $val;
          } else {
            $this->$key = $this->createObjectFromName($keyTypeName, $val);
          }
        } else if (is_array($val)) {
          $arrayObject = array();
          foreach ($val as $arrayIndex => $arrayItem) {
            $arrayObject[$arrayIndex] = $this->createObjectFromName($keyTypeName, $arrayItem);
          }
          $this->$key = $arrayObject;
        }
      }
    }
  }
1134499
public static function &changeArrayKey( &$array, $key='id' ) {
        $newArray = array();
        foreach ( $array as $value ) $newArray[$value[$key]] = $value;
        return $newArray;
    }
1008620
protected function _createInsertAndReplaceValues($array) {
		$keys = [];
		$values = [];
		$binds = [];
		
		foreach ($array as $value) {
			if (is_array($value)) {
				$values[] = $value['FUNC'];
			} else {
				$values[] = '?';
				$binds[] = $value;
			}
		}

		$keys = implode(',', array_keys($array));
		$values = implode(',', $values);
		
		$returner = compact('keys', 'values', 'binds');
		return $returner;
	}
1245448
private function convertIssuers($array)
    {
        $return = array();
        foreach ($array as $value) {
            array_push($return, array(
                'IssuerKeyword' => $value->IssuerKeyword,
                'Description' => $value->Description,
                'Countries' => $this->convertCountries($this->forceArray($value->Countries->Country))
                    )
            );
        }
        return $return;
    }
749329
public function arrayToObject(array $array): \stdClass
    {
        $objResult = new \stdClass();

        foreach ($array as $varKey => $varValue) {
            $objResult->{$varKey} = $varValue;
        }

        return $objResult;
    }
1373148
public function transform($collection)
    {
        if (null === $collection) {
            return null;
        }

        if (!($collection instanceof Collection)) {
            throw new UnexpectedTypeException($collection, 'Doctrine\Common\Collection\Collection');
        }

        $results = array();
        foreach ($collection as $entity) {
            $results[] = $this->accessor->getValue($entity, $this->identifier);
        }

        //Here, do not put the result in the cache because we must check the value in
        //reverseTransform (by QueryBuilder)

        return $results;
    }
901737
private function convertField($array)
    {
        $result = [];

        // Copy over well known keys.
        foreach (static::$convertFields as $key) {
            if (isset($array[$key])) {
                $result[$key] = $array[$key];
            }
        }

        if (isset($array['dataType'])) {
            $result['dataType'] = $this->inferType($array['dataType']);
        } else {
            $result['dataType'] = isset($array['children']) ? 'object' : DataTypes::STRING;
        }

        $result['required'] = isset($array['required']) && (bool) $array['required'];
        $result['readonly'] = isset($array['readonly']) && (bool) $array['readonly'];

        $result = $this->convertChildren($array, $result);

        return $result;
    }
671565
public function setCollection($array)
    {
        foreach ($array as $key => $object) {
            $class_name = "HelloSign\\{$this->resource_class}";
            $resource = new $class_name;
            $resource->fromObject($object);

            $this->collection[$key] = $resource;
        }

        return $this;
    }
634246
public static function remapArrayKeys(&$array, $mappingTable) {
		if (is_array($mappingTable)) {
			foreach ($mappingTable as $old => $new) {
				if ($new && isset($array[$old])) {
					$array[$new] = $array[$old];
					unset ($array[$old]);
				}
			}
		}
	}
490374
public static function fromPairs($array)
    {
        if (!is_array($array) && !($array instanceof \Traversable)) {
            throw new \InvalidArgumentException(sprintf(
                'Dictionary::fromPairs() argument must be array or Traversable, '
                . 'but is "%s".', gettype($array)
            ));
        }
        
        $result = new Dictionary();
        foreach ($array as $pair) {
            if (!is_array($pair) || !isset($pair[0]) || !isset($pair[1])) {
                throw new \InvalidArgumentException(
                    'Each element of array or Traversable passed to Dictionary::FromPairs()'
                    . ' must be two-elements array.'
                );
            }
            
            $result[$pair[0]] = $pair[1];
        }
        return $result;
    }
902091
protected function doCreateObject(array $array)
    {
        $order = new Order(isset($array['attributes']) && is_array($array['attributes']) ? $array['attributes'] : $array);
        $relationShips = $array['relationships'] ?? [];
        if (isset($relationShips['orderItems']) || isset($relationShips['items'])) {
            $mapper = new OrderItemsMapper();
            foreach ($relationShips['orderItems'] ?? $relationShips['items'] as $item) {
                $order->items[$item['id']] = $mapper->createObject($item);
            }
        }
        if (isset($relationShips['paymentMethods'])) {
            $mapper = new PaymentMethodsMapper();
            foreach ($relationShips['paymentMethods'] as $item) {
                $order->paymentMethods[$item['id']] = $mapper->createObject($item['attributes']);
            }
        }

        // old structure
        if (isset($array['items'])) {
            $orderItemMapper = new OrderItemsMapper();
            $order->items    = array_map(function ($item) use ($orderItemMapper) {
                return $orderItemMapper->createObject($item);
            }, $array['items']);
        }

        return $order;
    }