Returns a Reference to the root or the specified path.

@see https://firebase.google.com/docs/reference/js/firebase.database.Database#ref

@param string $path

@throws InvalidArgumentException

@return Reference
497686
public function getReference(string $path = null): Reference
    {
        try {
            return new Reference($this->uri->withPath($path ?? ''), $this->client);
        } catch (\InvalidArgumentException $e) {
            throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
        }
    }
948014
public static function setBaseDir($path)
    {
        $path = realpath(rtrim($path, '/\\ '));
        if ($path === false) {
            throw new \InvalidArgumentException("cat`t get real path: seems like path does`t exists: $path");
        }

        return static::$baseDir = $path;
    }
1179098
public function path(string $path) : PathList
    {
        if (!file_exists($path)) {
            throw new \InvalidArgumentException(
                'Arg path doesn\'t exist, path[' . $path . '].'
            );
        }
        if (!is_dir($path)) {
            throw new \InvalidArgumentException(
                'Arg path is not a directory, path[' . $path . '].'
            );
        }
        $this->path = $path;
        return $this;
    }
111142
public function load($path)
    {
        // Load template
        try {
            $template = $this->twig->loadTemplate($path);
        } catch (LoaderError $e) {
            throw new InvalidArgumentException("Error loading $path: ". $e->getMessage(), $e->getCode(), $e);
        }

        if ($template instanceof Template) {
            // Events are already fired by the View Environment
            $template->setFiredEvents(true);
        }

        return $template;
    }
884013
public function filePath($path)
    {
        $file = $this->realPath($path);
        if (!is_file($file)) {
            throw new \InvalidArgumentException(sprintf('The path is not a file: %s', $file));
        }

        return $path;
    }
1195575
public function tree($ref = 'HEAD', $path = null)
    {
        if ($path instanceof NodeObject) {
            $subjectPath = $path->getFullPath() . ($path->isTree() ? '/' : '');
        }
        else {
            $subjectPath = $path;
        }

        $what = $ref;
        if ($ref instanceof TreeishInterface) {
            $what = $ref->getSha();
        }
        $this->clearAll();
        $this->addCommandName(self::LS_TREE_COMMAND);
        $this->addCommandArgument('-l');
        $subject = $what;
        $this->addCommandSubject($subject);
        $this->addPath($subjectPath);

        return $this->getCommand();
    }
1105625
protected function ensurePath($path) {
    $real_path = $this->fileSystem->realpath($path);

    if (empty($real_path)) {
      throw new \InvalidArgumentException($path . ' does not exist.');
    }
    return $real_path;
  }
437395
public function lookup($context, $path, $require = false)
    {
        if (empty($path)) {
            throw new \InvalidArgumentException("Passed lookup path is empty.");
        }
        if (empty($context)) {
            throw new \InvalidArgumentException("Specified context is empty while resolving path " . json_encode($path));
        }
        return PropertyAccessor::getByPath($context, $this->path($path), $require);
    }
927834
protected function _path($path) {
		return $this->rootName.($path == $this->root ? '' : $this->separator.$this->_relpath($path));
	}
1121083
public function getResource($path)
    {
        $path = Path::normalise($path, true);
        if (empty($path)) {
            throw new InvalidArgumentException('$path is required');
        }
        if (isset($this->resources[$path])) {
            return $this->resources[$path];
        }
        return $this->resources[$path] = new ModuleResource($this, $path);
    }
1342527
public function getPath(string $path): Path
    {
        if (!$this->hasPath($path)) {
            throw new \InvalidArgumentException(
                "Path '$path' does not exist (have " . implode(', ', array_keys($this->paths)) . ')'
            );
        }

        return $this->paths[$path];
    }
1241289
public function setWebRootPath($path)
    {
        if (@file_exists($path) && is_dir($path)) {
            $this->web_root_path = realpath($path).'/';
        } else {
            throw new \InvalidArgumentException(
                sprintf('Web root path "%s" was not found or is not a directory!', $path)
            );
        }
        return $this;
    }
216090
public function base_path($path = null)
    {
        return empty($path) ? $this->path : $this->path . $path;
    }
643658
protected function checkPath($path)
    {
        // provide compatibility with objects such as \SplFileInfo
        if (is_object($path) && method_exists($path, '__toString')) {
            $path = (string) $path;
        }

        $handle = @fopen($path, 'r');

        if (false === $handle) {
            throw new InvalidArgumentException(sprintf('File %s does not exist.', $path));
        }

        fclose($handle);

        return $path.'[0]';
    }
359631
public function locate($path)
    {
        $repository = $this->getRepository();

        if(!$repository->contains($path)){
            throw new \InvalidArgumentException(sprintf('Their is no path %s in repository.', $path));
        }

        $resource = $repository->get($path);

        if(!($resource instanceof FilesystemResource)){
            throw new \RuntimeException(['Expect %s! %s given', FilesystemResource::class, get_class($resource)]);
        }

        return $resource;
    }
849576
protected function setPath($path)
    {
        $this->uriString = null;

        $path = (string) $path;

        if (strpos($path, '?') !== false) {
            throw new InvalidArgumentException(
                'Invalid path provided; must not contain a query string.'
            );
        }

        if (strpos($path, '#') !== false) {
            throw new InvalidArgumentException(
                'Invalid path provided; must not contain a URI fragment.'
            );
        }

        $this->path = static::encode($path);

        return $this;
    }
538291
private function lookup($path, \stdClass $document, string $uri = null)
    {
        $target = $this->lookupRecursively(
            explode('/', trim($path, '/#')),
            $document
        );
        if (!$target) {
            throw new InvalidReferenceException("Target '$path' does not exist'" . ($uri ? " at '$uri''" : ''));
        }

        return $target;
    }