Google\Cloud\Datastore\Key::normalizePath PHP Method

normalizePath() private method

Normalize the internal representation of a path
private normalizePath ( array $path ) : array
$path array
return array
    private function normalizePath(array $path)
    {
        // If the path is associative (i.e. not nested), wrap it up.
        if ($this->isAssoc($path)) {
            $path = [$path];
        }
        $res = [];
        foreach ($path as $index => $pathElement) {
            if (!isset($pathElement['kind'])) {
                throw new InvalidArgumentException('Each path element must contain a kind.');
            }
            $incomplete = !isset($pathElement['id']) && !isset($pathElement['name']);
            if ($index < count($path) - 1 && $incomplete) {
                throw new InvalidArgumentException('Only the final pathElement may omit a name or ID.');
            }
            if (isset($pathElement['id']) && !is_string($pathElement['id'])) {
                $pathElement['id'] = (string) $pathElement['id'];
            }
            $res[] = $pathElement;
        }
        return $res;
    }