src/ORM/FieldType/DBText.php
public function LimitSentences($maxSentences = 2)
    {
        if (!is_numeric($maxSentences)) {
            throw new InvalidArgumentException("Text::LimitSentence() expects one numeric argument");
        }

        $value = $this->Plain();
        if (!$value) {
            return "";
        }

        // Do a word-search
        $words = preg_split('/\s+/u', $value);
        $sentences = 0;
        foreach ($words as $i => $word) {
            if (preg_match('/(!|\?|\.)$/', $word) && !preg_match('/(Dr|Mr|Mrs|Ms|Miss|Sr|Jr|No)\.$/i', $word)) {
                $sentences++;
                if ($sentences >= $maxSentences) {
                    return implode(' ', array_slice($words, 0, $i + 1));
                }
            }
        }

        // Failing to find the number of sentences requested, fallback to a logical default
        if ($maxSentences > 1) {
            return $value;
        } else {
            // If searching for a single sentence (and there are none) just do a text summary
            return $this->Summary(20);
        }
    }
public function LimitSentences($maxSentences = 2)
    {
        if (!is_numeric($maxSentences)) {
            throw new InvalidArgumentException("Text::LimitSentence() expects one numeric argument");
        }

        $value = $this->Plain();
        if (!$value) {
            return "";
        }

        // Do a word-search
        $words = preg_split('/\s+/u', $value);
        $sentences = 0;
        foreach ($words as $i => $word) {
            if (preg_match('/(!|\?|\.)$/', $word) && !preg_match('/(Dr|Mr|Mrs|Ms|Miss|Sr|Jr|No)\.$/i', $word)) {
                $sentences++;
                if ($sentences >= $maxSentences) {
                    return implode(' ', array_slice($words, 0, $i + 1));
                }
            }
        }

        // Failing to find the number of sentences requested, fallback to a logical default
        if ($maxSentences > 1) {
            return $value;
        } else {
            // If searching for a single sentence (and there are none) just do a text summary
            return $this->Summary(20);
        }
    }
public function LimitSentences ( $ maxSentences = 2 ) { if ( ! is_numeric ( $ maxSentences ) ) { throw new InvalidArgumentException ( "Text::LimitSentence() expects one numeric argument" ) ; } $ value = $ this -> Plain ( ) ; if ( ! $ value ) { return "" ; } // Do a word-search $ words = preg_split ( '/\s+/u' , $ value ) ; $ sentences = 0 ; foreach ( $ words as $ i => $ word ) { if ( preg_match ( '/(!|\?|\.)$/' , $ word ) && ! preg_match ( '/(Dr|Mr|Mrs|Ms|Miss|Sr|Jr|No)\.$/i' , $ word ) ) { $ sentences ++ ; if ( $ sentences >= $ maxSentences ) { return implode ( ' ' , array_slice ( $ words , 0 , $ i + 1 ) ) ; } } } // Failing to find the number of sentences requested, fallback to a logical default if ( $ maxSentences > 1 ) { return $ value ; } else { // If searching for a single sentence (and there are none) just do a text summary return $ this -> Summary ( 20 ) ; } }
Limit sentences, can be controlled by passing an integer.

@param int $maxSentences The amount of sentences you want.
@return string
Limit sentences can be controlled by passing an integer .