Hydrates the instances for in a collection.

@param array[] $data      Map with a list of maps with instance data.
@return object[]          The deserialized items for in the collection.
@throws CannotDeserialize When deserialization of an item failed.
191288
private function itemsFromArray(array $data): array
    {
        $objects = [];
        foreach ($data[$this->key()] as $objectData) {
            $objects[] = $this->item->from($objectData);
        }
        return $objects;
    }
1268844
public function hydrate(array $items)
    {
        $instance = $this->newModelInstance();

        return $instance->newCollection(array_map(function ($item) use ($instance) {
            return $instance->newFromBuilder($item);
        }, $items));
    }
1258855
protected static function deserializeCommonAttributes(array $data)
    {
        $result = new static(isset($data['id']) ? $data['id'] : null);
        if ($result->getResourceType() != $data['meta']['resourceType']) {
            throw new \RuntimeException(sprintf('Error deserializing resource type "%s" into class "%s"', $data['meta']['resourceType'], get_class($result)));
        }
        $result->meta = Meta::deserializeObject($data['meta']);
        if (isset($arr['externalId'])) {
            $result->externalId = $data['externalId'];
        }
        if (isset($data['schemas'])) {
            foreach ($data['schemas'] as $schemaId) {
                if ($schemaId != $result->getSchemaId()) {
                    $result->extensions[$schemaId] = isset($data[$schemaId]) ? $data[$schemaId] : null;
                }
            }
        }

        return $result;
    }
992991
protected function convertArrayObjects($data)
    {
        if ($data instanceof Json\ArrayObject) {
            // @todo: Check if we need to convert arrays with only one single
            // element into non-arrays /cc cba
            $data = $data->getArrayCopy();
            foreach ($data as $key => $value) {
                $data[$key] = $this->convertArrayObjects($value);
            }
        } elseif ($data instanceof Json\JsonObject) {
            foreach ($data as $key => $value) {
                $data->$key = $this->convertArrayObjects($value);
            }
        }

        return $data;
    }
1105586
public static function toArray($data, array $propertyNameMapper = []): array
    {
        if (is_object($data)) {
            return self::entityToArray($data, $propertyNameMapper);
        }

        if (is_array($data)) {
            return self::arrayToArray($data, $propertyNameMapper);
        }

        return [$data];
    }
1125366
public static function fromData(array $data)
    {
        $reflection = new \ReflectionClass(static::class);
        $instance = $reflection->newInstanceWithoutConstructor();
        $instance->data = $data;
        $instance->jsonUnserialize($data);
        return $instance;
    }
930410
public function unserialize($data)
    {
        $object = @unserialize($data);
        if($object === false) {
            throw new SerializerException("Unable to unserialize data: " . $data);
        }

        return $object;
    }
969600
public function transform($data)
    {
        if (is_array($data)) {
            return $data;
        }

        if (is_object($data) && $data instanceof Arrayable) {
            return $data->toArray();
        }

        return (array) $data;
    }
560395
protected function asArray($data)
  {
    $array = [];
    
    foreach(get_object_vars((object)$data) as $k => $v){
      if ( is_object($v) ){
        $array[$k] = $this->asArray($v);
      }
      else {
        $array[$k] = $v;
      }
    }
    
    return $array;
  }
1186225
private function makeArraySerializable(array $data)
    {
        $serializable = [];

        foreach ($data as $key => $value) {
            if (is_object($value)) {
                $serializable[$key] = new ObjectStub($value);

                continue;
            }

            $serializable[$key] = is_array($value) ? $this->makeArraySerializable($value) : $value;
        }

        return $serializable;
    }
431180
protected function getQueuedCallable(array $data)
	{
		if (Str::contains($data['callback'], 'SerializableClosure'))
		{
			if ( class_exists('\SuperClosure\Serializer') )
			{
				return (new \SuperClosure\Serializer)->unserialize($data['callback']);
			}
			else
			{
				return with(unserialize($data['callback']))->getClosure();
			}
		}

		return $data['callback'];
	}
236956
protected function toArray( $data )
    {
        if ( is_object( $data ) )
        {
            $data = (array) $data;
        }
        if ( is_array( $data ) )
        {
           foreach( $data as $key => $val )
           {
               $data[$key] = $this->toArray( $val );
           }
        }
        return $data;
    }
18125
public function mapToObjects(array $objectsData)
    {
        $objects = [];
        foreach ($objectsData as $objectData) {
            $objects[] = $this->mapToObject($objectData);
        }

        return $objects;
    }
536213
public function hydrate( array $data, $object )
    {
        if ( isset( $data['properties'] ) &&
             is_array( $data['properties'] ) )
        {
            foreach ( $data['properties'] as $key => $value )
            {
                $newKey = String::decamelize( $key );

                if ( $newKey != $key )
                {
                    $data['properties'][$newKey] = $value;
                    unset( $data['properties'][$key] );
                }
            }
        }

        return $this->getMapper()
                    ->hydrate( $data, $object );
    }
800569
private function setObjectForCollectionData(array $data)
    {
        $objects = [];
        foreach ($data as $attribute => $object) {
            if (is_array($object) === false) {
                throw new MissingIdentifierAttribute();
            }

            $objects[$attribute] = $this->setObject($object);
        }

        return $objects;
    }
1153369
private function deserialize($data)
    {
        $result = json_decode(base64_decode($data, true), true);

        return is_array($result) ? $result : [];
    }
101006
private function toArrayInternal($data)
    {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                if (is_array($value)) {
                    $data[$key] = $this->toArrayInternal($value);
                }

                if (is_object($value)) {
                    $data[$key] = ArrayHelper::toArray($value);
                }
            }

            return $data;
        }
        elseif (is_object($data)) {
            return ArrayHelper::toArray($data);
        }
        else {
            return [$data];
        }
    }