Unwrap the instances from response
@param $provider
@param $array
@return array
@throws \ReflectionException
763255
protected static function formItems($provider, $array)
    {
        $set = [];

        foreach ($array['items'] as $params) {
            $instance = new static($provider, array_merge($params, ['exists' => true]));
            $instance->cacheFields($params);
            if (isset($instance->id)) {
                $set[$instance->id] = $instance;
            } else {
                $set[] = $instance;
            }
        }

        return $set;
    }
704691
public function unwrap()
    {
        $iterator = $this->getInnerIterator();

        if ($iterator instanceof CollectionInterface) {
            $iterator = $iterator->unwrap();
        }

        if (get_class($iterator) !== ArrayIterator::class) {
            return $this;
        }

        // ArrayIterator can be traversed strictly.
        // Let's do that for performance gains

        $callback = $this->_extractor;
        $res = [];

        foreach ($iterator->getArrayCopy() as $k => $v) {
            $res[$k] = $callback($v);
        }

        return new ArrayIterator($res);
    }
409524
public function packMap(array $array)
    {
        $size = count($array);
        $b = '';
        $b .= $this->getMapSizeMarker($size);

        foreach ($array as $k => $v) {
            $b .= $this->pack($k);
            $b .= $this->pack($v);
        }

        return $b;
    }
385872
public function unwrapValue($value)
    {
        if (is_array($value)) {
            $self = $this;
            return array_map(function ($item) use ($self) {
                if ($item instanceof Context) {
                    return $item->unwrap();
                } else {
                    return $self->unwrapValue($item);
                }
            }, $value);
        } else {
            return $value;
        }
    }
700367
public function unshift(array $array, $element): array
    {
        // get all elements that are supposed to be added
        $elements = func_get_args();
        array_shift($elements);
        foreach ($elements as $element) {
            array_unshift($array, $element);
        }
        return $array;
    }
376290
public function getProvider($provider)
    {
        $name = is_string($provider) ? $provider : get_class($provider);
        return \Nip_Helper_Arrays::first($this->providers, function ($value) use ($name) {
            return $value instanceof $name;
        });
    }
1252232
public function reverseTransform($array)
    {
        $ret = new ArrayCollection();

        foreach ($array as $el) {
            $ret->add(
                $this->em
                    ->getRepository($this->class)
                    ->find($el)
            );
        }
        return $ret;
    }
1120611
public function transform($array)
    {
        $className = $this->className;
        $viewReference = new $className();
        foreach ($array as $prop => $value) {
            $methodName = 'set'.ucfirst($prop);
            $viewReference->$methodName((string) $value);
        }

        return $viewReference;
    }
88836
public static function arrayClone(array $array)
    {
        return array_map(function ($element) {
                return ((is_array($element))
                    ? call_user_func(__FUNCTION__, $element)
                    : ((is_object($element))
                        ? clone $element
                        : $element
                    )
                );
        }, $array);
    }
921957
protected function unformatPayloadData(array $data)
    {
        $unformattedData = array();

        foreach ($data as $key => $value) {
            $newKey = $this->deserializeColumnName($key);

            if (is_array($value)) {
                $newValue = $this->unformatPayloadData($value);
            } else {
                $newValue = $value;
            }

            $unformattedData[$newKey] = $newValue;
        }

        return $unformattedData;
    }
1279501
public function unmarshall(array $data = array())
    {
        $private_properties = array(
            'row_wrapper_class',
            'index_field',
            'options'
        );

        foreach ($private_properties as $property) {
            if (isset($data[$property])) {
                $this->$property = $data[$property];
            } else {
                $this->$property = null;
            }
        }

        $this->objects = array();
        $this->objects_by_index = array();
        if (is_subclass_of($this->row_wrapper_class, 'SwatDBMarshallable')) {
            if (isset($data['objects'])) {
                foreach ($data['objects'] as $object_data) {
                    $object = new $this->row_wrapper_class();
                    $object->unmarshall($object_data);
                    $this->objects[] = $object;
                }
            }
            if ($this->index_field != '') {
                $this->reindex();
            }
        }
    }
1047747
public static function unflatten(array $array, $delimiter = '.')
    {
        $unflattenedArray = array();

        foreach ($array as $key => $value) {
            $keyList  = explode($delimiter, $key);
            $firstKey = array_shift($keyList);

            if (sizeof($keyList) > 0) {
                $subArray = static::unflatten(array( implode($delimiter, $keyList) => $value ), $delimiter);

                foreach ($subArray as $subArrayKey => $subArrayValue) {
                    $unflattenedArray[ $firstKey ][ $subArrayKey ] = $subArrayValue;
                }
            } else {
                $unflattenedArray[ $firstKey ] = $value;
            }
        }

        return $unflattenedArray;
    }
329473
public static function reindex(array $array, array $map, bool $unmapped = true): array
    {
        $reindexed = $unmapped
            ? $array
            : [];

        foreach ($map as $from => $to) {
            if (isset($array[$from])) {
                $reindexed[$to] = $array[$from];
            }
        }

        return $reindexed;
    }
861687
private function convertToArray(DataProviderInterface $provider): array
    {
        $data = [];
        foreach ($provider->getElements() as $element) {
            $fieldname = $element['isCamelCase'] ? $this->convertUnderlines($element['name']) : $element['name'];
            $hasMethod = 'has' . $fieldname;
            if ($provider->$hasMethod()) {
                $data = $this->getDataFromFields($provider, $fieldname, $element, $data);
            }
        }

        return $data;
    }
655635
protected function filterProviders(array $providers)
    {
        if (empty($providers)) {
            return $this->providers;
        }

        return array_intersect_key($this->providers, array_flip($providers));
    }
925973
protected function reflection($handler)
    {
        if (! is_array($handler))
        {
            $instance = new \ReflectionFunction($handler);

            return array($handler, $instance);
        }

        list($class, $method) = (array) $handler;

        $instance = new \ReflectionMethod($class, $method);

        $handler = array($this->instance($class), $method);

        return array((array) $handler, $instance);
    }
70213
private function getArray(Array_ $array)
    {
        $return = [];

        foreach ($array->items as $item) {
            if ($item->key === null) {
                $return[] = $this->getValue($item->value);
            } else {
                $return[$this->getValue($item->key)] = $this->getValue($item->value);
            }
        }

        return $return;
    }