public function setTemplate($name, $path)
    {
        if (! isset($this->templates[$name])) {
            throw new UnexpectedValueException(sprintf(
                'Unexpected template name "%s" provided.',
                is_string($name) ? $name : gettype($name)
            ));
        }

        $finfo    = new SplFileInfo($path);
        $realPath = $finfo->getRealPath();
        if (! $realPath) {
            throw new InvalidArgumentException(sprintf(
                'Invalid path "%s" of template "%s" provided.',
                $path,
                $name
            ));
        }
        $extension = $finfo->getExtension();
        if ('phtml' !== $extension) {
            throw new InvalidArgumentException(sprintf(
                'Invalid file extension "%s" of template "%s"; the extension '
                . 'of template file must be "phtml".',
                $extension,
                $name
            ));
        }
        $this->templates[$name] = $realPath;
    }