Documentation

Orthography

Utility functions for checking the orthography of arbitrary text strings.

An orthography is a set of conventions for writing a language. It includes norms of spelling, hyphenation, capitalization, word breaks, emphasis, and punctuation. Source: https://en.wikipedia.org/wiki/Orthography

Table of Contents

TERMINAL_POINTS Characters which are considered terminal points for a sentence. '.?!'
isFirstCharCapitalized() Check if the first character of an arbitrary text string is a capital letter. bool
isFirstCharLowercase() Check if the first character of an arbitrary text string is a lowercase letter. bool
isLastCharPunctuation() Check if the last character of an arbitrary text string is a valid punctuation character. bool

Constants

TERMINAL_POINTS

Characters which are considered terminal points for a sentence.

string $TERMINAL_POINTS = '.?!'

Methods

isFirstCharCapitalized()

Check if the first character of an arbitrary text string is a capital letter.

public static isFirstCharCapitalized( $string : string ) : bool

Letter characters which do not have a concept of lower/uppercase will be accepted as correctly capitalized.

Parameters
$string : string

The text string to examine. This can be the contents of a text string token, but also, for instance, a comment text. Potential text delimiter quotes should be stripped off a text string before passing it to this method.

Tags
since
Return values
bool

True when the first character is a capital letter or a letter which doesn't have a concept of capitalization. False otherwise, including for non-letter characters.

isFirstCharLowercase()

Check if the first character of an arbitrary text string is a lowercase letter.

public static isFirstCharLowercase( $string : string ) : bool
Parameters
$string : string

The text string to examine. This can be the contents of a text string token, but also, for instance, a comment text. Potential text delimiter quotes should be stripped off a text string before passing it to this method.

Tags
since
Return values
bool

True when the first character is a lowercase letter. False otherwise, including for letters which don't have a concept of capitalization and for non-letter characters.

isLastCharPunctuation()

Check if the last character of an arbitrary text string is a valid punctuation character.

public static isLastCharPunctuation( $string : string [, $allowedChars : string = self::TERMINAL_POINTS ] ) : bool
Parameters
$string : string

The text string to examine. This can be the contents of a text string token, but also, for instance, a comment text. Potential text delimiter quotes should be stripped off a text string before passing it to this method.

$allowedChars : string = self::TERMINAL_POINTS

Characters which are considered valid punctuation to end the text string. Defaults to '.?!', i.e. a full stop, question mark or exclamation mark.

Tags
since
Return values
bool

Search results