PHPCSUtils

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

Tags
since
1.0.0

Table of Contents

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

Constants

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. Also see: {@see \PHPCSUtils\Utils\TextStrings::stripQuotes()}.

Tags
since
1.0.0
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. Also see: {@see \PHPCSUtils\Utils\TextStrings::stripQuotes()}.

Tags
since
1.0.0
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[, string $allowedChars = 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. Also see: {@see \PHPCSUtils\Utils\TextStrings::stripQuotes()}.

$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
1.0.0
Return values
bool

Search results