@param array|object $data
@param string|null $parent

@return array
346983
public static function buildHttpQuery($data, ?string $parent = null): array
    {
        $result = [];

        if (is_object($data)) {
            $data = get_object_vars($data);
        }

        foreach ($data as $key => $value) {
            if ($parent) {
                $new_key = sprintf('%s[%s]', $parent, $key);
            } else {
                $new_key = $key;
            }

            if (!$value instanceof CURLFile && (is_array($value) || is_object($value))) {
                $result = array_merge($result, self::buildHttpQuery($value, $new_key));
            } else {
                $result[$new_key] = $value;
            }
        }

        return $result;
    }
905117
protected static function buildTree(&$data, $rootID = 0)
    {
        $tree = [];

        foreach ($data as $id => $node) {
            if ($node->parentId == $rootID) {
                unset($data[$id]);
                $node->children = self::buildTree($data, $node->id);
                $tree[] = $node;
            }
        }

        return $tree;
    }
743070
private function array2ArgsWithInjectDependency($parent, array $array = array())
    {   
        $args = array();
        foreach ($array as $_key => $_val) {
            if (is_string($_val) && preg_match('/^\$([\w_]+)$/', $_val, $matches)) {
                $args[] = sprintf('$this->container->get("%s")', $matches[1]);
            } else {
                $args[] = is_numeric($_key) ? sprintf('%s[%s]', $parent, $_key) : sprintf("%s['%s']", $parent, $_key) ;
            }   
        }   
        return join(', ', $args);
    }
444126
public function createEntity(array $data = [], EntityInterface $parent_entity = null, $apply_default_values = false)
    {
        return parent::createEntity($data, $parent_entity, true);
    }
683563
protected function processResourceData(array $resourceData, array $parentModels, $type)
    {
        try {
            $this->seenTypes[$type] = $resourceData;
            return parent::processResourceData($resourceData, $parentModels, $type);
        } catch (MissingResolverException $exception) {
        } catch (\ReflectionException $exception) {
        }

        return null;
    }
52769
public function fields($parent, array $fields)
    {
        foreach ($fields as $id => $field) {
            if (!isset($field['id'])) {
                $field['id'] = $id;
            }
            if (!isset($field['name'])) {
                $field['name'] = $id;
            }
            $this->field($parent, $field);
        }
    }
948135
public function buildTree($data, $row_level = 'parent')
    {
        $new = [];
        foreach ($data as $a) {
            if (null === $a->{$row_level}) {
                $a->{$row_level} = 0;
            }
            $new[$a->{$row_level}][] = $a;
        }

        return $this->createTree($new, Arr::get($new, 0, []));
    }
357725
public function addItem($parentId, $data)
    {
        if (empty($parentId)) {
            $this->items[0][] = $data;
        } else {
            $this->items[$parentId][] = $data;
        }
    }
1262159
public function get(string $parent, string $name, string $entry = null)
    {
        $key = $parent. '.' . $name;
        if (!empty($entry)) {
            $key .= '.' . $entry;
        }
        return data_get($this->data, $key, null);
    }
552427
public function automaticParentId($data)
	{
		if (!isset($data['parent_id']))
		{
			$data['parent_id'] = 0;
		}

		if ((!isset($data['id']) || !$data['id'])
		 && ($data['parent_id'] == 0))
		{
			$data['parent_id'] = self::getRootId();
		}

		return $data['parent_id'];
	}
379951
protected function responseToArray($node, $parent = null)
    {
        $array = array();
        foreach ($node as $k => $v) {
            if ($this->isChildFromList($k, $parent)) { // current value is a list
                if ($v instanceof \Countable && count($v) == 1 && $k != '0') { // a list with 1 element. It's returned with a 0-index
                    $array[$k][0] = PaylineSDK::responseToArray($v, $k);
                } elseif (is_object($v) || is_array($v)) { // a list with more than 1 element
                    $array[$k] = PaylineSDK::responseToArray($v, $k);
                } else {
                    $array[$k] = $v;
                }
            } else {
                if (is_object($v) || is_array($v)) {
                    $array[$k] = PaylineSDK::responseToArray($v, $k);
                } else {
                    $array[$k] = $v;
                }
            }
        }
        return $array;
    }
639458
private function getParentClasses(string $class, $parentClass = []) : array
    {
        if (!$parentClass) {
            $parentClass[] = $class;
        }

        $parent = get_parent_class($class);
        if ($parent) {
            $parentClass[] = $parent;
            $parentClass = self::getParentClasses($parent, $parentClass);
        }

        return $parentClass;
    }
10881
public List<L> parseComponent(@Nullable C parent, @Nullable T data) {
        return mDataParser.parseComponent(data, parent, this);
    }
492028
public static function buildHTTPCurlQuery($data, $parent = false)
    {
        $result = array();

        if (is_object($data)) {
            $data = get_object_vars($data);
        }

        foreach ($data as $key => $value) {
            if ($parent) {
                $new_key = sprintf('%s[%s]', $parent, $key);
            } else {
                $new_key = $key;
            }

            if (!$value instanceof \CURLFile and (is_array($value) or is_object($value))) {
                $result = array_merge($result, self::buildHTTPCurlQuery($value, $new_key));
            } else {
                $result[$new_key] = $value;
            }
        }

        return $result;
    }
988978
private function valuesToFormParameters($values, $parent)
    {
        $ret = array();
        foreach ($values as $key => $value) {
            if (null !== $parent) {
                $keyName = sprintf('%s[%s]', $parent, $key);
            } else {
                $keyName = $key;
            }
            if (is_scalar($value)) {
                $ret[$keyName] = $value;
            } else {
                $ret = array_merge($ret, $this->valuesToFormParameters($value, $keyName));
            }
        }
        return $ret;
    }
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;
    }
796742
public function getTree($parentId = null, $recursive = true)
    {
        $queryBuilder = $this->driver->getSelectQueryBuilder();
        if ($parentId === null) {
            $queryBuilder->andWhere($this->getParentField() . " IS NULL");
        } else {
            $queryBuilder->andWhere($this->getParentField() . " = " . $parentId);
        }
        $statement  = $queryBuilder->execute();
        $rows       = $statement->fetchAll();
        $hasResults = count($rows) > 0;

        // Cast array to DataItem array list
        if ($hasResults) {
            $this->driver->prepareResults($rows);
        }

        if ($recursive) {
            /** @var DataItem $dataItem */
            foreach ($rows as $dataItem) {
                $dataItem->setChildren($this->getTree($dataItem->getId(), $recursive));
            }
        }

        return $rows;
    }