PHP Класс DaveChild\TextStatistics\Text

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$blnMbstring boolean Efficiency: Is the MB String extension loaded?
$clean array Efficiency: Store strings once processed.

Открытые методы

Метод Описание
averageWordsPerSentence ( string $strText, string $strEncoding = '' ) : integer | float Returns average words per sentence for text.
characterCount ( string $strText, string $strEncoding = '' ) : integer Alias for textLength, as "letterCount", "wordCount" etc also used
cleanText ( string | boolean $strText ) : string Trims, removes line breaks, multiple spaces and generally cleans text before processing.
letterCount ( string $strText, string $strEncoding = '' ) : integer Gives letter count (ignores all non-letters). Tries mb_strlen and if that fails uses regular strlen.
lowerCase ( string $strText, string $strEncoding = '' ) : string Converts string to lower case. Tries mb_strtolower and if that fails uses regular strtolower.
sentenceCount ( string $strText, string $strEncoding = '' ) : integer Returns sentence count for text.
substring ( string $strText, integer $intStart, integer $intLength, string $strEncoding = '' ) : string Gets portion of string. Tries mb_substr and if that fails uses regular substr.
textLength ( string $strText, string $strEncoding = '' ) : integer Gives string length. Tries mb_strlen and if that fails uses regular strlen.
upperCase ( string $strText, string $strEncoding = '' ) : string Converts string to upper case. Tries mb_strtoupper and if that fails uses regular strtoupper.
wordCount ( string $strText, string $strEncoding = '' ) : integer Returns word count for text.

Описание методов

averageWordsPerSentence() публичный статический Метод

Returns average words per sentence for text.
public static averageWordsPerSentence ( string $strText, string $strEncoding = '' ) : integer | float
$strText string Text to be measured
$strEncoding string Encoding of text
Результат integer | float

characterCount() публичный статический Метод

Alias for textLength, as "letterCount", "wordCount" etc also used
public static characterCount ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
Результат integer

cleanText() публичный статический Метод

Trims, removes line breaks, multiple spaces and generally cleans text before processing.
public static cleanText ( string | boolean $strText ) : string
$strText string | boolean Text to be transformed
Результат string

letterCount() публичный статический Метод

Gives letter count (ignores all non-letters). Tries mb_strlen and if that fails uses regular strlen.
public static letterCount ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
Результат integer

lowerCase() публичный статический Метод

Converts string to lower case. Tries mb_strtolower and if that fails uses regular strtolower.
public static lowerCase ( string $strText, string $strEncoding = '' ) : string
$strText string Text to be transformed
$strEncoding string Encoding of text
Результат string

sentenceCount() публичный статический Метод

Returns sentence count for text.
public static sentenceCount ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
Результат integer

substring() публичный статический Метод

Gets portion of string. Tries mb_substr and if that fails uses regular substr.
public static substring ( string $strText, integer $intStart, integer $intLength, string $strEncoding = '' ) : string
$strText string Text to be cut up
$intStart integer Start character
$intLength integer Length
$strEncoding string Encoding of text
Результат string

textLength() публичный статический Метод

Gives string length. Tries mb_strlen and if that fails uses regular strlen.
public static textLength ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
Результат integer

upperCase() публичный статический Метод

Converts string to upper case. Tries mb_strtoupper and if that fails uses regular strtoupper.
public static upperCase ( string $strText, string $strEncoding = '' ) : string
$strText string Text to be transformed
$strEncoding string Encoding of text
Результат string

wordCount() публичный статический Метод

Returns word count for text.
public static wordCount ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
Результат integer

Описание свойств

$blnMbstring защищенное статическое свойство

Efficiency: Is the MB String extension loaded?
protected static bool $blnMbstring
Результат boolean

$clean защищенное статическое свойство

Efficiency: Store strings once processed.
protected static array $clean
Результат array