public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = [])
    {
        if (is_array($destination)) {
            $parameters = $destination;
            $destination = null;
        } elseif (is_array($extension)) {
            $parameters = $extension;
            $extension = '.html';
        }
        if (!$destination) {
            $destination = $path;
        }
        $path = realpath($path);
        $destination = realpath($destination);

        $success = 0;
        $errors = 0;
        if ($path && $destination) {
            $path = rtrim($path, '/\\');
            $destination = rtrim($destination, '/\\');
            $length = mb_strlen($path);
            foreach ($this->scanDirectory($path) as $file) {
                $relativeDirectory = trim(mb_substr(dirname($file), $length), '//\\');
                $filename = pathinfo($file, PATHINFO_FILENAME);
                $outputDirectory = $destination.DIRECTORY_SEPARATOR.$relativeDirectory;
                $counter = $this->renderAndWriteFile(
                    $file,
                    $outputDirectory.DIRECTORY_SEPARATOR.$filename.$extension,
                    $parameters
                ) ? 'success' : 'errors';
                $$counter++;
            }
        }

        return [$success, $errors];
    }