Html::resume_name PHP Method

resume_name() static public method

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

Usage Example

Example #1
0
 /**
  * @covers Html::resume_name
  */
 public function testResume_name()
 {
     $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_name($origin));
     $origin = 'A string that is longer than 10 characters.';
     $expected = 'A string t...';
     $this->assertEquals($expected, Html::resume_name($origin, 10));
 }
Html