timostamm / text-truncation
dev-master
2017-10-03 16:11 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ~6.3
This package is auto-updated.
Last update: 2024-12-05 19:52:47 UTC
README
This utility truncates plain text to a maximum length. It recognizes paragraphs, sentences and words and uses them to cut the text in a smart way.
Example
// Setup a truncation for a maximum string length of 370 characters. // Use the Paragraph-Strategy, which tries to find a paragraph // within the first 370 characters, and falls back to a sentence or // a word. $t = new Truncation( 370, Truncation::STRATEGY_PARAGRAPH ); // Apply the truncation $txt = $t->truncate( $x );