/** * @dataProvider trimTextDataProvider */ public function testTrimToHTML($html, $length, $nbsp, $hellip, $striptags, $expected) { if ($hellip) { $ellipseStr = '…'; } else { $ellipseStr = ''; } $actual = trimToHTML($html, $length, $ellipseStr, $striptags, $nbsp); $this->assertEquals($expected, $actual); }
/** * Wrapper around trimToHTML for backwards-compatibility * * @param string $str String to trim * @param int $desiredLength Target string length * @param bool $nbsp Transform spaces to their html entity * @param bool $hellip Add dots when the string is too long * @param bool $striptags Strip html tags * @return string Trimmed string */ function trimText($str, $desiredLength, $nbsp = false, $hellip = true, $striptags = true) { if ($hellip) { $ellipseStr = '…'; } else { $ellipseStr = ''; } return trimToHTML($str, $desiredLength, $ellipseStr, $striptags, $nbsp); }