public static function minimizeEntities($text)
    {
        // decode any entities that might already exist
        $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');

        // encode all ampersands (&), less than (<), greater than (>),
        // and double quote (") characters as their XML entities
        $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');

        return $text;
    }