public function setRootDirectory($directory)
    {
        if (!is_dir($directory)) {
            throw new \DomainException(sprintf(
                'The value "%s" defined as the root directory does not exist.',
                $directory
            ));
        }
        $this->directory = $directory;
        return $this;
    }