Returns an array containing normalized elements

@used-by InterfaSys\LogNormalizer\Normalizer::normalize

@param $data
@param int $depth

@return array|null
356489
private function normalizeTraversable($data, $depth = 0) {
		if (is_array($data) || $data instanceof \Traversable) {
			return $this->normalizeTraversableElement($data, $depth);
		}

		return null;
	}
1018806
protected function normalizeData(array $data, $parentId = null) {
        $result = [];
        foreach ($data as $element) {
            if (ArrayHelper::getValue($element, $this->parentColumnName) === $parentId) {
                $result[] = $element;
                $children = $this->normalizeData($data, ArrayHelper::getValue($element, $this->keyColumnName));
                if ($children) {
                    $result = array_merge($result, $children);
                }
            }
        }
        return $result;
    }
1039868
static function decodeElementRawData(string $data): ?array
    {
        $data = json_decode($data, true);
        if (is_array($data) &&
                isset($data['id']) && is_string($data['id']) && strlen($data['id']) > 0 &&
                isset($data['type']) && is_string($data['type']) && strlen($data['type']) > 0 &&
                isset($data['data']) && is_array($data['data'])
        ) {
            return $data;
        }
        return null;
    }
176404
private function normalizeData($data, \stdClass $schema)
    {
        if (\is_array($data)) {
            return $this->normalizeArray(
                $data,
                $schema
            );
        }

        if ($data instanceof \stdClass) {
            return $this->normalizeObject(
                $data,
                $schema
            );
        }

        return $data;
    }
358964
private function normalizeData($name, $data)
    {
        if (!isset($this->ignoreProcessing[$name])) {
            return array_map('trim', explode(',', $data));
        } else {
            return [$data];
        }
    }
746086
private function getPermissions($items = null, $depth = 0)
    {
        $permissions = array();

        if ($items === null) {
            $items = $this->owner->getAuthItems();
        }

        foreach ($items as $itemName => $item) {
            $permissions[$itemName] = array(
                'name' => $itemName,
                'item' => $item,
                'children' => $this->getPermissions($item, $depth + 1),
                'depth' => $depth,
            );
        }

        return $permissions;
    }
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;
    }
1306624
protected function normalizePathData(array $pathData)
    {
        $normalizedPathData = array();
        foreach ($pathData as $level => $rows) {
            $pathElementData = array();
            foreach ($rows as $row) {
                $this->normalizePathDataRow($pathElementData, $row);
            }

            $normalizedPathData[$level] = $pathElementData;
        }

        return $normalizedPathData;
    }
605348
protected function normalize(array $data, int $n)
    {
        if (empty($this->means)) {
            $this->calculateMeans($data, $n);
        }

        // Normalize data
        foreach ($data as $i => $row) {
            for ($k = 0; $k < $n; ++$k) {
                $data[$i][$k] -= $this->means[$k];
            }
        }

        return $data;
    }
1266097
protected function normalizeErrorResponse($content, $data = null)
    {
        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        }

        if ( ! is_array($content)) {
            $content = [
                'message' => $content,
            ];
        }

        if (null !== $data) {
            $content['data'] = $data;
        }

        return $content;
    }
731130
protected function normalizeArray(array $data)
    {
        $ret = [];

        foreach ($data as $key => $value) {
            if (!\is_string($key)) {
                continue;
            }

            $ret[$key[0]] = [
                'value' => $value,
                'pattern' => $key,
            ];
        }

        return $ret;
    }
196380
protected function resolveNestedRelations($data):array
    {
        if (is_null($data)) {
            return [];
        }

        $data = $data instanceof Model ? [$data] : $data;

        return collect($data)->flatMap(function ($model) {
            $relations = collect($model->getRelations());

            return $relations->keys()->merge($relations->flatMap(function ($relation, $key) {
                return collect($this->resolveNestedRelations($relation))->map(function ($nestedRelation) use ($key) {
                    return $key . '.' . $nestedRelation;
                });
            }));
        })->unique()->toArray();
    }
165523
protected function normalizeData( $data )
	{
		// If an object was provided, get its public properties
		if( is_object( $data )) {
			$this->data = get_object_vars( $data );
		}
		else {
			$this->data = $data;
		}

		return $this;
	}
530155
private function searchTree(int $depth = 0)
    {
        $this->depth = $depth;
        foreach ($this->children->getList() as $node) {
            if ($depth > count($this->treePath)) {
                break;
            }

            if ($this->treePath[$depth] != $node->key) {
                continue;
            }

            /**
             * @var $node TreeNode
             */
            if (count($this->treePath) > $depth && $this->allowedToDiveDeeper($depth)) {
                $node->setTreePath($this->treePath);

                return $node->searchTree(++$depth);
            }
        }

        return $this;
    }
447512
public function filterNodeDepth($nodes, $depth)
    {
        if(empty($nodes) || $depth === 0)
        {
            return array();
        }

        $newNodes = array();
        $stack = array();
        $level = 0;

        foreach($nodes as $node)
        {
            $parent = end($stack);
            while($parent && $node->getLeftValue() > $parent->getRightValue())
            {
                array_pop($stack);
                $parent = end($stack);
                $level--;
            }

            if($level < $depth)
            {
                $newNodes[] = $node;
            }

            if(($node->getRightValue() - $node->getLeftValue()) > 1)
            {
                array_push($stack, $node);
                $level++;
            }
        }

        return $newNodes;
    }
810389
protected function normalize(array $data, string $prefix = null): array
    {
        if ($prefix) {
            $prefix .= '.';
        }

        $result = [];
        foreach ($data as $item) {
            $value = [
                'label' => (string)$item['label'],
                'inactive' => (bool)$item['inactive']
            ];

            if (! empty($item['children'])) {
                $value['children'] = $this->normalize($item['children'], $prefix . $item['value']);
            }
            $result[$prefix . $item['value']] = $value;
        }

        return $result;
    }
432219
public static function flatten(array $array, $depth = INF) : array
    {
        $depth = is_int($depth) ? max($depth, 0) : INF;

        return array_reduce($array, function ($result, $item) use ($depth) {
            if (!is_array($item) || $depth === 0) {
                return array_merge($result, [$item]);
            } elseif ($depth === 1) {
                return array_merge($result, array_values($item));
            } else {
                return array_merge($result, self::flatten($item, $depth - 1));
            }
        }, []);
    }