private function setYamlPath(string $yamlPath): void
    {
        $chars = preg_quote(':._-\/\\\\', '#');
        $pattern = '#^[\w' . $chars . ']+\.(yaml|yml)$#';
        if (!preg_match($pattern, $yamlPath)) {
            throw new ParserException('Given path to YAML file is invalid');
        }

        // Get absolute path to file, resolve symbolic links (if any)
        $givenPath = $yamlPath;
        $yamlPath = realpath($yamlPath);
        if (!$yamlPath) {
            throw new ParserException(
                sprintf('YAML file "%s" not found in directory "%s"', basename($givenPath), dirname($givenPath))
            );
        }

        $this->yamlPath = $yamlPath;
        $this->baseDirectory = dirname($this->yamlPath);
    }