Gives the Automated Readability Index of text entered rounded to one digit
@param   boolean|string  $strText         Text to be checked
@return  int|float
763390
public function automatedReadabilityIndex($strText = false)
    {
        $strText = $this->setText($strText);

        $score = Maths::bcCalc(
            Maths::bcCalc(
                4.71,
                '*',
                Maths::bcCalc(
                    Text::letterCount($strText, $this->strEncoding),
                    '/',
                    Text::wordCount($strText, $this->strEncoding)
                )
            ),
            '+',
            Maths::bcCalc(
                Maths::bcCalc(
                    0.5,
                    '*',
                    Maths::bcCalc(
                        Text::wordCount($strText, $this->strEncoding),
                        '/',
                        Text::sentenceCount($strText, $this->strEncoding)
                    )
                ),
                '-',
                21.43
            )
        );

        if ($this->normalise) {
            return Maths::normaliseScore($score, 0, $this->maxGradeLevel, $this->dps);
        } else {
            return Maths::bcCalc($score, '+', 0, true, $this->dps);
        }
    }
232432
public static function letterCount($strText, $strEncoding = '')
    {
        if (strlen(trim($strText)) == 0) {
            return 0;
        }

        if (is_null(self::$blnMbstring)) {
            self::$blnMbstring = extension_loaded('mbstring');
        }

        $strText = self::cleanText($strText); // To clear out newlines etc
        $intTextLength = 0;
        $strText = preg_replace('`[^A-Za-z]+`', '', $strText);
        try {

            if (!self::$blnMbstring) {
                throw new \Exception('The extension mbstring is not loaded.');
            }

            if ($strEncoding == '') {
                $intTextLength = mb_strlen($strText);
            } else {
                $intTextLength = mb_strlen($strText, $strEncoding);
            }
        } catch (\Exception $e) {
            $intTextLength = strlen($strText);
        }

        return $intTextLength;
    }
867296
public static double fleschKincaidGradeLevel(String strText) {
        strText = cleanText(strText);
        return PHPMethods.round(((0.39 * averageWordsPerSentence(strText)) + (11.8 * averageSyllablesPerWord(strText)) - 15.59), 1);
    }
982538
public function count($match = null, $exact = false)
    {
        if (!is_null($match)) {
            $keys = $this->index->getKeys();

            if ($exact) {
                $match = "^{$match}$";
            }

            $matches = array_filter($keys, function($key) use ($match) {
                return preg_match("/{$match}/i", $key);
            });

            return sizeof($matches);
        }

        return $this->index->count();
    }
123168
public static double daleChallGrade(String strText) {
        //http://rfptemplates.technologyevaluation.com/dale-chall-list-of-3000-simple-words.html
        double score=daleChallScore(strText);
        if(score<5.0) {
            return 2.5;
        }
        else if(score<6.0) {
            return 5.5;
        }
        else if(score<7.0) {
            return 7.5;
        }
        else if(score<8.0) {
            return 9.5;
        }
        else if(score<9.0) {
            return 11.5;
        }
        else if(score<10.0) {
            return 14.0;
        }
        else {
            return 16.0;
        }
    }
517727
public function parse(string $text)
    {
        if (! is_numeric($text))
            throw new ParseException($this, $text, 0, self::ERROR);
        return $text + 0;
    }
1043086
public function readLatitude(string $text): float
    {
        return $this->readDegrees($text, self::LATITUDE_NORTH, self::LATITUDE_SOUTH);
    }
857588
public static double colemanLiauIndex(String strText) {
        strText = cleanText(strText);
        int intWordCount = wordCount(strText);
        return PHPMethods.round( ( (5.89 * (letterCount(strText) / (double)intWordCount)) - (0.3 * (sentenceCount(strText) / (double)intWordCount)) - 15.8 ), 1);
    }
1188952
protected function evaluateInput($digit)
    {
        if ($this->inputIsCancel($digit)) {
            return self::INPUT_CANCEL;
        }
        if ($this->inputIsEnd($digit)) {
            return self::INPUT_END;
        }
        return self::INPUT_NORMAL;
    }
690104
public static function ctype_digit($text)
    {
        $text = self::convert_int_to_char_for_ctype($text);

        return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
    }
604619
protected function parseAttr($text)
    {
        $atts = [];

        $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';

        $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);

        if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) )
        {
            foreach ($match as $m)
            {
                if (!empty($m[1]))
                    $atts[strtolower($m[1])] = stripcslashes($m[2]);
                elseif (!empty($m[3]))
                    $atts[strtolower($m[3])] = stripcslashes($m[4]);
                elseif (!empty($m[5]))
                    $atts[strtolower($m[5])] = stripcslashes($m[6]);
                elseif (isset($m[7]) and strlen($m[7]))
                    $atts[] = stripcslashes($m[7]);
                elseif (isset($m[8]))
                    $atts[] = stripcslashes($m[8]);
            }
        }
        else
        {
            $atts = ltrim($text);
        }

        return $atts;
    }
652053
public static double fleschKincaidReadingEase(String strText) {
        strText = cleanText(strText);
        return PHPMethods.round((206.835 - (1.015 * averageWordsPerSentence(strText)) - (84.6 * averageSyllablesPerWord(strText))), 1);
    }
1137799
public function spacheDifficultWordCount($strText = false)
    {
        $strText = $this->setText($strText);
        $intDifficultWords = 0;
        $arrWords = explode(' ', strtolower(preg_replace('`[^A-za-z\' ]`', '', $strText)));
        // Fetch Spache Words
        $wordsCounted = array();

        // Get the Spache word list
        $arrSpache = Resource::fetchSpacheWordList();

        for ($i = 0, $intWordCount = count($arrWords); $i < $intWordCount; $i++) {
            // Single letters are counted as easy
            if (strlen(trim($arrWords[$i])) < 2) {
                continue;
            }
            $singularWord = Pluralise::getSingular($arrWords[$i]);
            if ((!in_array(Pluralise::getPlural($arrWords[$i]), $arrSpache)) && (!in_array($singularWord, $arrSpache))) {
                if (!in_array($singularWord, $wordsCounted)) {
                    $intDifficultWords++;
                    $wordsCounted[] = $singularWord;
                }
            }
        }

        return $intDifficultWords;
    }
560356
public function getPercentage($round = true)
    {
        if ($this->translated === 0 || $this->total === 0) {
            $result = $round ? 0 : 0.0;
        } elseif ($this->translated === $this->total) {
            $result = $round ? 100 : 100.0;
        } else {
            $result = $this->translated * 100.0 / $this->total;
            if ($round) {
                $result = max(1, min(99, (int) round($result)));
            }
        }

        return $result;
    }
1149998
public static function averageSyllablesPerWord($strText, $strEncoding = '')
    {
        $intSyllableCount = 0;
        $intWordCount = Text::wordCount($strText, $strEncoding);
        $arrWords = explode(' ', $strText);
        for ($i = 0; $i < $intWordCount; $i++) {
            $intSyllableCount += self::syllableCount($arrWords[$i], $strEncoding);
        }
        $averageSyllables = (Maths::bcCalc($intSyllableCount, '/', $intWordCount));
        return $averageSyllables;
    }
176558
private static int matchesAt(CharSequence text, int offsetInText, CharSequence substring) {
        int len = substring.length();
        int textLength = text.length();
        if (textLength + offsetInText > len) {
            return -1;
        }
        int i = 0;
        for (int j = offsetInText; i < len; ++i, ++j) {
            char pc = substring.charAt(i);
            char tc = text.charAt(j);
            if (pc != tc) return -1;
        }
        return i;
    }
80133
public static double daleChallScore(String strText) {
        strText = cleanText(strText);
        int intDifficultWordCount = 0;
        List<String> arrWords = (new WhitespaceTokenizer()).tokenize(strText);
        int intWordCount = arrWords.size();
        for (int i = 0; i < intWordCount; ++i) {
            if (!DALECHALL_WORDLIST.contains(arrWords.get(i))) {
                ++intDifficultWordCount;
            }
        }
        int intSentenceCount=sentenceCount(strText);

        double percentageOfDifficultWords=intDifficultWordCount/(double)intWordCount;
        double score=0.1579*(100*percentageOfDifficultWords)+0.0496*(intWordCount/(double)intSentenceCount);
        if(percentageOfDifficultWords>0.05) {
            score+=3.6365;
        }

        return score;
    }