Including template file and replacing variables

<?php

class EmailTemplate
{

    protected $template = '/templates/welcome.phtml';
    private $data;

    /**
     * 
     * @param array $data Data available in template file $this->template
     * @return boolean
     */
    public function setData(array $data)
    {
        if (empty($data)) {
            return false;
        }
        $this->data = $data;
        return true;
    }

    /**
     * 
     * @return string Template file that uses the private variables e.g. $this->data
     * @throws \RuntimeException
     */
    public function getComputedTemplate(): string
    {
        if (empty($this->template)) {
            throw new \RuntimeException('Template path is not set.');
        }
        if (!file_exists(self::$phproot . $this->template)) {
            throw new \RuntimeException('Template path does not exist: ' . $this->template);
        }
        ob_start();
        include self::$phproot . $this->template;
        return ob_get_clean();
    }

}