public function addScriptFunction($name, $text = null)
    {
        if ($name instanceof ScriptFunction) {
            $scriptFunction = $name;
        } else {
            $scriptFunction = new ScriptFunction($name, $text);
        }
        if (!in_array($scriptFunction, $this->functions)) {
            array_push($this->functions, $scriptFunction);
        }
        return $this;
    }