Create from array.

@param array $array

@return Item
977309
public static function createFromArray(array $array): self
    {
        if (
            !isset($array['uuid']) ||
            !is_array($array['uuid'])
        ) {
            throw InvalidFormatException::itemUUIDRepresentationNotValid($array['uuid'] ?? []);
        }

        if (
            isset($array['coordinate']) &&
            !is_array($array['coordinate'])
        ) {
            throw InvalidFormatException::coordinateFormatNotValid();
        }

        $item = isset($array['coordinate'])
            ? self::createLocated(
                ItemUUID::createFromArray($array['uuid']),
                Coordinate::createFromArray($array['coordinate']),
                $array['metadata'] ?? [],
                $array['indexed_metadata'] ?? [],
                $array['searchable_metadata'] ?? [],
                $array['exact_matching_metadata'] ?? [],
                $array['suggest'] ?? []
            )
            : self::create(
                ItemUUID::createFromArray($array['uuid']),
                $array['metadata'] ?? [],
                $array['indexed_metadata'] ?? [],
                $array['searchable_metadata'] ?? [],
                $array['exact_matching_metadata'] ?? [],
                $array['suggest'] ?? []
            );

        if (isset($array['distance'])) {
            $item->distance = (float) $array['distance'];
        }

        if (isset($array['highlights'])) {
            $item->highlights = $array['highlights'];
        }

        if (isset($array['is_promoted']) && true === $array['is_promoted']) {
            $item->setPromoted();
        }

        if (isset($array['score']) && !is_null($array['score'])) {
            $item->setScore((float) $array['score']);
        }

        return $item;
    }
1300763
protected function doCreateObject(array $array)
    {
        $this->data = $array;
        $this->document = new Document($this->data);
        $this->setFunctionalNames()
             ->setAttributes()
             ->setMedia();

        return $this->document;
    }
762958
protected function doCreateObject(array $array)
    {
        $entityFactor = new EntityFactor($array);

        $factor = [
            'id'            => $array['factorId'] ?? null,
            'code'          => $array['factorCode'] ?? null,
            'name'          => $array['factorName'] ?? null,
        ];
        $mapper = new FactorsMapper();
        $entityFactor->factor = $mapper->createObject($factor);

        $factorValue = [
            'id'            => $array['id'] ?? null,
            'name'          => $array['name'] ?? null,
            'factorId'      => $array['factorId'] ?? null,
            'image'         => $array['image'] ?? null,
            'description'   => $array['description'] ?? null,
        ];
        $mapper = new FactorValuesMapper();
        $entityFactor->factorValue = $mapper->createObject($factorValue);

        return $entityFactor;
    }
948047
protected function serializeArray(array $array) {
        $data = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $data[$key] = $this->serializeArray($value);
            } else {
                $data[$key] = $this->serializeItem($value);
            }
        }

        return $data;
    }
1160957
public function createArray(array $items): Array_
    {
        $arrayItems = [];

        foreach ($items as $item) {
            $arrayItems[] = $this->createArrayItem($item);
        }

        return new Array_($arrayItems);
    }
62579
private
    static function objectify(
        array $array
    ) {
        foreach ($array as &$item) {
            if (is_array($item)) {
                $item = self::objectify($item);
            }
        }

        return (object)$array;
    }
422046
public static function fromArray($entity, array $array)
    {
        if (is_string($entity)) {
            $entity = InstanceHelper::createInstanceWithoutConstructor($entity);
        }

        $reflectionPropertyList = InstanceHelper::getReflectionProperties($entity);
        ClassHelper::setReflectionPropertiesAccessible($reflectionPropertyList);

        /** @var ReflectionProperty $reflectionProperty */
        foreach ($reflectionPropertyList as $reflectionProperty) {
            $propertyName = $reflectionProperty->getName();
            if (array_key_exists($propertyName, $array)) {
                $reflectionProperty->setValue($entity, $array[$propertyName]);
            }
        }

        return $entity;
    }
1040187
public function fromArray($array) {
		$array=parent::fromArray($array);
		foreach ( $array as $key => $value ) {
			$this->setProperty($key, $value);
		}
		return $array;
	}
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();
  }
338184
public static function fromArray(array $array)
    {
        $hostname       = $array['hostname'] ?? null;
        $challengeTs    = $array['challenge_ts'] ?? null;
        $apkPackageName = $array['apk_package_name'] ?? null;
        $score          = isset($array['score']) ? floatval($array['score']) : null;
        $action         = $array['action'] ?? null;

        if (isset($array['success']) && $array['success'] == true)
            return new static(true, [], $hostname, $challengeTs, $apkPackageName, $score, $action);

        if ( ! (isset($array['error-codes']) && is_array($array['error-codes'])))
            $array['error-codes'] = [ResponseV3::E_UNKNOWN_ERROR];

        return new static(false, $array['error-codes'], $hostname, $challengeTs, $apkPackageName, $score, $action);
    }
470933
public static function createFromArray(array $array): self
    {
        $activeElements = [];
        foreach (($array['active_elements'] ?? []) as $activeElement) {
            $activeElements[] = is_array($activeElement)
                ? Counter::createFromArray($activeElement)
                : $activeElement;
        }

        $aggregation = new self(
            $array['name'],
            (int) ($array['application_type'] ?? Filter::AT_LEAST_ONE),
            (int) ($array['total_elements'] ?? 0),
            []
        );
        $aggregation->activeElements = $activeElements;
        $counters = array_map(function (array $counter) {
            return Counter::createFromArray($counter);
        }, $array['counters'] ?? []);
        foreach ($counters as $counter) {
            $aggregation->counters[$counter->getId()] = $counter;
        }

        $aggregation->highestActiveLevel = $array['highest_active_level'] ?? 0;

        return $aggregation;
    }
890945
public function fromArray(array $array)
    {
        $this->removeAll();
        foreach ($array as $name => $values) {
            if (\is_array($values)) {
                foreach ($values as $value) {
                    $this->add($name, $value);
                }
            } else {
                $this->add($name, $values);
            }
        }
    }
1372661
protected function doCreateObject(array $array)
    {
        $factor = new Factor($array);

        if (isset($array['factorValues']) && is_array($array['factorValues'])) {

            foreach ($array['factorValues'] as $factorValueData) {
                $mapper = new FactorValuesMapper();
                $factor->values[] = $mapper->createObject($factorValueData);
            }
        }

        return $factor;
    }
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;
    }
849048
public static function createFromArray(array $array): self
    {
        if (!isset($array['uuid'], $array['app_id'])) {
            throw InvalidFormatException::indexFormatNotValid();
        }

        return new self(
            IndexUUID::createFromArray($array['uuid']),
            AppUUID::createFromArray($array['app_id']),
            $array['is_ok'] ?? false,
            $array['doc_count'] ?? 0,
            $array['size'] ?? '0kb',
            $array['shards'] ?? Config::DEFAULT_SHARDS,
            $array['replicas'] ?? Config::DEFAULT_REPLICAS,
            $array['fields'] ?? [],
            $array['metadata'] ?? []
        );
    }
603771
public static function buildObject($array) {
		$obj = new \stdClass();

		foreach ($array as $key => $value) {
			if (is_array($value)) {
				$obj->{$key} = self::buildObject($value);
			} else {
				$obj->{$key} = $value;
			}
		}

		return $obj;
	}
1163740
public static function createFromArray(?array $array): ?BinarySearchTree {
        if (null === $array) {
            return null;
        }
        $tree = new BinarySearchTree();
        if (0 === \count($array)) {
            return $tree;
        }
        foreach ($array as $element) {
            if (null === $element) {
                continue;
            }
            $tree->insertValue($element);
        }
        return $tree;
    }