public static function toTitleCase($string)
    {

        // Replace underscores, dashes with spaces
        $string = str_replace(["_", "-"], " ", $string);

        // Break the string into an array of words
        $name_array = explode(" ", $string);

        // Words not-to capitalize
        $smallWords = [
            'of','a','the','and','an','or','nor','but','is','if','then','else','when',
            'at','from','by','on','off','for','in','out','over','to','into','with'
        ];

        $acronyms = Settings::getInstance()->getAcronyms();

        foreach ($name_array as $index => $value) {
            if (in_array($value, $acronyms) === true) {
                $name_array[$index] = strtoupper($value);
            } elseif ($index === 0 || $index === sizeof($name_array) - 1) {
                $name_array[$index] = ucfirst($value);
            } elseif (in_array($value, $smallWords) === true) {
                // do nothing
            } else {
                $name_array[$index] = ucfirst($value);
            }
        }

        // Recombine the array into a single string, and convert to capital case
        $string = implode(" ", $name_array);

        return $string;
    }