diff --git a/spec/Coduo/PHPHumanizer/StringSpec.php b/spec/Coduo/PHPHumanizer/StringSpec.php index 6d2125e..6e8deeb 100644 --- a/spec/Coduo/PHPHumanizer/StringSpec.php +++ b/spec/Coduo/PHPHumanizer/StringSpec.php @@ -52,20 +52,20 @@ function it_truncate_string_to_word_closest_to_a_certain_number_of_characters_wi $text = '
HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create web pages.[1] Web browsers can read HTML files and render them into visible or audible web pages. HTML describes the structure of a website semantically along with cues for presentation, making it a markup language, rather than a programming language.
'; // Test with allowed tags - $this->truncateHtml($text, 3)->shouldReturn("HyperText"); - $this->truncateHtml($text, 12)->shouldReturn("HyperText Markup"); - $this->truncateHtml($text, 30)->shouldReturn("HyperText Markup Language, commonly"); - $this->truncateHtml($text, 50)->shouldReturn("HyperText Markup Language, commonly referred to as"); - $this->truncateHtml($text, 75)->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup'); - $this->truncateHtml($text, 100)->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create'); + $this->truncateHtml($text, 3, '')->shouldReturn("HyperText"); + $this->truncateHtml($text, 12, '')->shouldReturn("HyperText Markup"); + $this->truncateHtml($text, 30, '')->shouldReturn("HyperText Markup Language, commonly"); + $this->truncateHtml($text, 50, '')->shouldReturn("HyperText Markup Language, commonly referred to as"); + $this->truncateHtml($text, 75, '')->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup'); + $this->truncateHtml($text, 100, '')->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create'); // Test without tags - $this->truncateHtml($text, 3, '')->shouldReturn("HyperText"); - $this->truncateHtml($text, 12, '')->shouldReturn("HyperText Markup"); - $this->truncateHtml($text, 50, '')->shouldReturn("HyperText Markup Language, commonly referred to as"); - $this->truncateHtml($text, 75, '')->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup'); - $this->truncateHtml($text, 100, '')->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create'); + $this->truncateHtml($text, 3)->shouldReturn("HyperText"); + $this->truncateHtml($text, 12)->shouldReturn("HyperText Markup"); + $this->truncateHtml($text, 50)->shouldReturn("HyperText Markup Language, commonly referred to as"); + $this->truncateHtml($text, 75)->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup'); + $this->truncateHtml($text, 100)->shouldReturn('HyperText Markup Language, commonly referred to as HTML, is the standard markup language used to create'); // Test with append $this->truncateHtml($text, 50, '', '...')->shouldReturn("HyperText Markup Language, commonly referred to as..."); diff --git a/src/Coduo/PHPHumanizer/String.php b/src/Coduo/PHPHumanizer/String.php index 74b28e9..13b1a85 100644 --- a/src/Coduo/PHPHumanizer/String.php +++ b/src/Coduo/PHPHumanizer/String.php @@ -39,7 +39,7 @@ public static function truncate($text, $charactersCount, $append = '') * @param string $append * @return string */ - public static function truncateHtml($text, $charactersCount, $allowedTags = '', $append = '') + public static function truncateHtml($text, $charactersCount, $allowedTags = '', $append = '') { $truncate = new HtmlTruncate(new WordBreakpoint(), $allowedTags, $append); diff --git a/src/Coduo/PHPHumanizer/String/HtmlTruncate.php b/src/Coduo/PHPHumanizer/String/HtmlTruncate.php index 474d985..5e011b1 100644 --- a/src/Coduo/PHPHumanizer/String/HtmlTruncate.php +++ b/src/Coduo/PHPHumanizer/String/HtmlTruncate.php @@ -24,7 +24,7 @@ class HtmlTruncate implements TruncateInterface * @param string $allowedTags * @param string $append */ - public function __construct(Breakpoint $breakpoint, $allowedTags = '', $append = '') + public function __construct(Breakpoint $breakpoint, $allowedTags = '', $append = '') { $this->breakpoint = $breakpoint; $this->append = $append;