PHP Class DaveChild\TextStatistics\Text

Datei anzeigen Open project: nystudio107/seomatic Class Usage Examples

Protected Properties

Property Type Description
$blnMbstring boolean Efficiency: Is the MB String extension loaded?
$clean array Efficiency: Store strings once processed.

Public Methods

Method Description
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.

Method Details

averageWordsPerSentence() public static method

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
return integer | float

characterCount() public static method

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
return integer

cleanText() public static method

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
return string

letterCount() public static method

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
return integer

lowerCase() public static method

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
return string

sentenceCount() public static method

Returns sentence count for text.
public static sentenceCount ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
return integer

substring() public static method

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
return string

textLength() public static method

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
return integer

upperCase() public static method

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
return string

wordCount() public static method

Returns word count for text.
public static wordCount ( string $strText, string $strEncoding = '' ) : integer
$strText string Text to be measured
$strEncoding string Encoding of text
return integer

Property Details

$blnMbstring protected_oe static_oe property

Efficiency: Is the MB String extension loaded?
protected static bool $blnMbstring
return boolean

$clean protected_oe static_oe property

Efficiency: Store strings once processed.
protected static array $clean
return array