Html::resume_text PHP Method

resume_text() static public method

Resume text for followup
static public resume_text ( $string, $length = 255 ) : cut
$string string string to resume
$length integer resume length (default 255)
return cut string
    static function resume_text($string, $length = 255)
    {
        if (Toolbox::strlen($string) > $length) {
            $string = Toolbox::substr($string, 0, $length) . " (...)";
        }
        return $string;
    }

Usage Example

Example #1
0
 /**
  * @covers Html::resume_text
  */
 public function testResume_text()
 {
     $origin = 'This is a very long string which will be truncated by a dedicated method. ' . 'If the string is not truncated, well... We\'re wrong and got a very serious issue in our codebase!' . 'And if the string has been correctly truncated, well... All is ok then, let\'s show if all the other tests are OK :)';
     $expected = 'This is a very long string which will be truncated by a dedicated method. ' . 'If the string is not truncated, well... We\'re wrong and got a very serious issue in our codebase!' . 'And if the string has been correctly truncated, well... All is ok then, let\'s show i (...)';
     $this->assertEquals($expected, Html::resume_text($origin));
     $origin = 'A string that is longer than 10 characters.';
     $expected = 'A string t (...)';
     $this->assertEquals($expected, Html::resume_text($origin, 10));
 }
All Usage Examples Of Html::resume_text
Html