Convert given input data array to a ObjectList object

@param array|null $data
@return ObjectInFolderContainer[]
518939
public function convertDescendants(array $data = null)
    {
        return array_filter(
            array_map(
                [$this, 'convertDescendant'],
                $data ?? []
            ),
            function ($item) { return !empty($item); }
        );
    }
783856
public function data(array $data = null)
    {
        if (is_null($data)) {
            return $this->data;
        }

        $this->data = $data;

        return $this;
    }
908250
public function createMany(array $data, $modelClass = null)
    {
        $models = [];
        foreach ($data as $item) {
            $models[] = $this->fromArray($item, $modelClass);
        }

        return $models;
    }
565810
public static function getList($data)
    {
        // Return Null if Null
        if ($data === null) {
            return null;
        }

        if (is_a($data, get_class(new \stdClass()))) {
            //This means, root element is object

            $accessibleProperties = get_object_vars($data);

            if (count($accessibleProperties) == 1
                && (isset($accessibleProperties['error']) || isset($accessibleProperties['errors']))
            ) {
                // Object is only an error {"error":"message"} or {"errors":["error1":"message1"]}
                return new Error(JsonConverter::encode($data));
            } else {
                return new static(JsonConverter::encode($data));
            }
        }

        $list = array();

        if (is_array($data)) {
            $data = JsonConverter::encode($data);
        }

        if (JsonValidator::validate($data)) {
            // It is valid JSON
            $decoded = JsonConverter::decode($data);
            if ($decoded === null) {
                return $list;
            }
            if (is_array($decoded)) {
                foreach ($decoded as $k => $v) {
                    $list[] = self::getList($v);
                }
            }
            if (is_a($decoded, get_class(new \stdClass()))) {
                //This means, root element is object
                $list[] = new static(JsonConverter::encode($decoded));
            }
        }

        return $list;
    }
384067
final public static function getInstance($data=null)
    {
        $class = get_called_class();
        if (empty($class)) return null;

        if (empty($data)){
            $classID = $class;

        } elseif(is_array($data)){
            $classID = $class.md5(implode('', array_keys($data)));

        } else {
            $classID = $class.md5($data);
        }

        if (!isset(self::$_instances[$classID])){
            self::$_instances[$classID] = new $class($data);
        }

        return self::$_instances[$classID];
    }
1156193
public function convertObjectParents(array $data = null)
    {
        return array_filter(
            array_map(
                [$this, 'convertObjectParentData'],
                (array) ($data ?? [])
            ),
            function ($item) {
                return !empty($item);
                // @TODO once a logger is available we should log an INFO message if the parent data could not be converted
            }
        );
    }
1063712
protected function objectToArray(stdClass $data = null)
    {
        if (null !== $data) {
            $data = (array) $data;
            foreach ($data as $key => $value) {
                if ($value instanceof stdClass) {
                    $data[$key] = $this->objectToArray($value);
                }
            }
        }

        return $data;
    }
658523
public static function fromArray(array $data = [])
    {
        $obj = new static();

        foreach ($data as $v) {
            $obj->addNode(Node::factory($v));
        }

        return $obj;
    }
1205007
protected function createObjectFromData(array $data) {
    // determine if we are loading or creating
    $createFromLoadedData = (sizeof($data) > 0) ? true : false;

    // initialize data and oid
    $oid = null;
    $initialData = $data;
    if ($createFromLoadedData) {
      $oid = $this->constructOID($initialData);
      // cleanup data
      foreach($initialData as $name => $value) {
        if ($this->hasAttribute($name) || strpos($name, self::INTERNAL_VALUE_PREFIX) === 0) {
          $value = $this->convertValueFromStorage($name, $value);
          $initialData[$name] = $value;
        }
        else {
          unset($initialData[$name]);
        }
      }
    }

    // construct object
    $object = $this->createObject($oid, $initialData);
    return $object;
  }
92273
private function convertSerializedToArray($data)
    {
        $data = @unserialize($data);

        // Maybe the response was a serialized JSON string
        // So let's try to convert that to an array...
        if (is_string($data))
        {
            return $this->convertJsonToArray($data);
        }

        // It could be an object or an array of object
        // but we want a associative array, so use
        // JSON to encode it and then decode it properly...
        if ((is_object($data) or is_array($data)) and $json = $this->convertToJson($data))
        {
            return $this->convertJsonToArray($json);
        }

        return null;
    }
20883
public function reverseTransform($data)
    {
        if (is_array($data)) {
            $id = current($data);
            $document = $this->objectManager->find($this->documentClass, $id);

            return $this->entityDbMapper->fromEntityToDb($document);
        }

        return null;
    }
593848
public static function normalizeArray($data)
    {
        if ($data instanceof DataObjectInterface) {
            $data = $data->getData();
        } else if ($data instanceof \ArrayObject) {
            $data = $data->getArrayCopy();
        } else if ($data instanceof \Traversable) {
            $data = iterator_to_array($data);
        }

        if (!is_array($data)) throw new \InvalidArgumentException();

        return $data;
    }
180283
private function prepareResponseData($data)
    {
        switch (true)
        {
            case is_object($data):
                if (method_exists($data, 'toArray'))
                {
                    $data = $data->toArray();
                }
                else
                {
                    $data = get_object_vars($data);
                }
                $data = $this->prepareResponseData($data);
                break;
            case is_array($data):
                foreach ($data as $key => $value)
                {
                    $data[$key] = $this->prepareResponseData($value);
                }
                break;
        }
        return $data;
    }
717439
protected function parseData($data=null)
    {
        if (!$data) $data = $this->def['data'];
        
        if (is_array($data)) {
            foreach ($data as $k => $v) {
                if (strpos($v, '@') === 0 && class_exists('\CURLFile')) {
                    $v = ltrim($v, '@');
                    $data[$k] = new \CURLFile($v);
                }
            }
        }
        
        return $data;
    }
381582
public function data(array $properties = null)
    {
        $data = [];
        $properties = $this->properties($properties);
        foreach ($properties as $propertyIdent => $property) {
            // Ensure objects are properly encoded.
            $val = $this->propertyValue($propertyIdent);
            $val = $this->serializedValue($val);
            $data[$propertyIdent] = $val;
        }

        return $data;
    }
884369
public static function deserializeObject(array $data)
    {
        $subAttributes = [];
        if (isset($data['subAttributes'])) {
            foreach ($data['subAttributes'] as $subAttribute) {
                $subAttributes[] = static::deserializeObject($subAttribute);
            }
        }
        $result = new static(
            $data['name'],
            $data['type'],
            $data['multiValued'],
            $data['required'],
            isset($data['description']) ? $data['description'] : null,
            $subAttributes,
            isset($data['canonicalValues']) ? $data['canonicalValues'] : [],
            isset($data['caseExact']) ? $data['caseExact'] : false,
            $data['mutability'],
            $data['returned'],
            isset($data['uniqueness']) ? $data['uniqueness'] : null,
            isset($data['referenceTypes']) ? $data['referenceTypes'] : []
        );

        return $result;
    }
1374487
protected function fromArray($data)
    {
        if (empty($data)) {
            return $this;
        }

        $this->data = array_replace_recursive($this->data, $data);

        return $this;
    }