Hacking Fusion Invoice v2.6.5 to work on PHP 7

I'm currently running Fusion Invoice v2.6.5 for well, my invoicing. I keep meaning to get round to purchasing a new license for it to keep updated, but I haven't had the time to get round to it.

When I moved to PHP 7, the only issue I've encounted with Fusion Invoice is when sending an email, it'd throw "cannot use object of type stdclass as array". So I did some digging and found out that the problem class was app/FI/Libraries. The original file was like so:

<?php
/* license comments here */
namespace FI\Libraries;

class Parser {

    public static function parse($object, $string)
    {
        if (preg_match_all('/{{([^{|}]*)}}/', $string, $vars))
        {
            foreach ($vars[1] as $var)
    {
                $varMap = explode('->', trim($var));
                array_shift($varMap);

                switch (count($varMap))
                {
                    case 1:
                        $replace = $object->$varMap[0];
                        break;
                    case 2:
                        $replace = $object->$varMap[0]->$varMap[1];
                        break;
                    case 3:
            $replace = $object->$varMap[0]->$varMap[1]->$varMap[2];
                        break;
                    case 4:
    $replace = $object->$varMap[0]->$varMap[1]->$varMap[2]->$varMap[3];
                        break;
                }
        $string = str_replace('{{' . $var . '}}', $replace, $string);
            }
        }
        return $string;
    }
}

and the "fix" is...

<?php
/* license comments here */

namespace FI\Libraries;

class Parser {

    public static function parse($object, $string)
    {
        if (preg_match_all('/{{([^{|}]*)}}/', $string, $vars))
        {
            foreach ($vars[1] as $var)
            {
                $varMap = explode('->', trim($var));
                array_shift($varMap);

                $zero = $varMap[0];
                $one = isset($varMap[1]) ? $varMap[1] : null;
                $two = isset($varMap[2]) ? $varMap[2] : null;
                $three = isset($varMap[3]) ? $varMap[3] : null;
                switch (count($varMap))
                {
                    case 1:
                        $replace = $object->$zero;
    break;
                    case 2:
                        $replace = $object->$zero->$one;
                    break;
                    case 3:
                        $replace = $object->$zero->$one->$two;
                break;
                    case 4:
                        $replace = $object->$zero->$one->$two->$three;
            break;
                }
                $string = str_replace('{{' . $var . '}}', $replace, $string);
            }
    }
        return $string;
    }
}

It isn't a good fix, or even a good hack but it works for the time being.