function _determineCase($word)
    {
        $ret = -1;
        $trimmedword = trim($word);
        /*We need this variable. Without the next of would not work
         (trim changes the variable automatically to a string!)*/
        if (is_string($word) && (strlen($trimmedword) > 0)) {
            $i = 0;
            $found = false;
            $openbrace = 0;
            while (!$found && ($i <= strlen($word))) {
                $letter = substr($trimmedword, $i, 1);
                $ord = ord($letter);
                if ($ord == 123) { //Open brace
                    $openbrace++;
                }
                if ($ord == 125) { //Closing brace
                    $openbrace--;
                }
                if (($ord >= 65) && ($ord <= 90) && (0 == $openbrace)) { //The first character is uppercase
                    $ret = 1;
                    $found = true;
                } elseif (($ord >= 97) && ($ord <= 122) && (0 == $openbrace)) { //The first character is lowercase
                    $ret = 0;
                    $found = true;
                } else { //Not yet found
                    $i++;
                }
            }
        } else {
            throw new BibtexException('Could not determine case on word: ' . (string)$word);
        }
        return $ret;
    }
function _determineCase($word)
    {
        $ret = -1;
        $trimmedword = trim($word);
        /*We need this variable. Without the next of would not work
         (trim changes the variable automatically to a string!)*/
        if (is_string($word) && (strlen($trimmedword) > 0)) {
            $i = 0;
            $found = false;
            $openbrace = 0;
            while (!$found && ($i <= strlen($word))) {
                $letter = substr($trimmedword, $i, 1);
                $ord = ord($letter);
                if ($ord == 123) { //Open brace
                    $openbrace++;
                }
                if ($ord == 125) { //Closing brace
                    $openbrace--;
                }
                if (($ord >= 65) && ($ord <= 90) && (0 == $openbrace)) { //The first character is uppercase
                    $ret = 1;
                    $found = true;
                } elseif (($ord >= 97) && ($ord <= 122) && (0 == $openbrace)) { //The first character is lowercase
                    $ret = 0;
                    $found = true;
                } else { //Not yet found
                    $i++;
                }
            }
        } else {
            throw new BibtexException('Could not determine case on word: ' . (string)$word);
        }
        return $ret;
    }
function _determineCase ( $ word ) { $ ret = - 1 ; $ trimmedword = trim ( $ word ) ; /*We need this variable. Without the next of would not work
         (trim changes the variable automatically to a string!)*/ if ( is_string ( $ word ) && ( strlen ( $ trimmedword ) > 0 ) ) { $ i = 0 ; $ found = false ; $ openbrace = 0 ; while ( ! $ found && ( $ i <= strlen ( $ word ) ) ) { $ letter = substr ( $ trimmedword , $ i , 1 ) ; $ ord = ord ( $ letter ) ; if ( $ ord == 123 ) { //Open brace $ openbrace ++ ; } if ( $ ord == 125 ) { //Closing brace $ openbrace -- ; } if ( ( $ ord >= 65 ) && ( $ ord <= 90 ) && ( 0 == $ openbrace ) ) { //The first character is uppercase $ ret = 1 ; $ found = true ; } elseif ( ( $ ord >= 97 ) && ( $ ord <= 122 ) && ( 0 == $ openbrace ) ) { //The first character is lowercase $ ret = 0 ; $ found = true ; } else { //Not yet found $ i ++ ; } } } else { throw new BibtexException ( 'Could not determine case on word: ' . ( string ) $ word ) ; } return $ ret ; }
Case Determination according to the needs of BibTex

To parse the Author(s) correctly a determination is needed
to get the Case of a word. There are three possible values:
- Upper Case (return value 1)
- Lower Case (return value 0)
- Caseless   (return value -1)

@access private
@param string $word
@return int The Case
@throws BibtexException
Case Determination according to the needs of BibTex