@@ -356,17 +356,17 @@ |
||
356 | 356 | return Inflector::transliterate($string, $transliterator); |
357 | 357 | } |
358 | 358 | |
359 | - /** |
|
360 | - * Limits a string by word count. If $substring is provided, and truncating occurs, the |
|
361 | - * string is further truncated so that the substring may be appended without |
|
362 | - * exceeding the desired length. |
|
363 | - * |
|
364 | - * @param string $string |
|
365 | - * @param int $length |
|
366 | - * @param string $substring |
|
367 | - * |
|
368 | - * @return string |
|
369 | - */ |
|
359 | + /** |
|
360 | + * Limits a string by word count. If $substring is provided, and truncating occurs, the |
|
361 | + * string is further truncated so that the substring may be appended without |
|
362 | + * exceeding the desired length. |
|
363 | + * |
|
364 | + * @param string $string |
|
365 | + * @param int $length |
|
366 | + * @param string $substring |
|
367 | + * |
|
368 | + * @return string |
|
369 | + */ |
|
370 | 370 | public function wordLimit(string $string, int $length, string $substring = '…'): string |
371 | 371 | { |
372 | 372 | $words = preg_split("/[\s]+/", strip_tags($string) ); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | if (!empty($string)) { |
145 | 145 | $string = strip_tags($string); |
146 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
146 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $result; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | if (!empty($string)) { |
169 | 169 | $string = strip_tags($string); |
170 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
170 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return $result; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | */ |
370 | 370 | public function wordLimit(string $string, int $length, string $substring = '…'): string |
371 | 371 | { |
372 | - $words = preg_split("/[\s]+/", strip_tags($string) ); |
|
373 | - return implode(" ", array_slice($words, 0, $length) ) . $substring; |
|
372 | + $words = preg_split("/[\s]+/", strip_tags($string)); |
|
373 | + return implode(" ", array_slice($words, 0, $length)).$substring; |
|
374 | 374 | } |
375 | 375 | } |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | public function getFilters() |
41 | 41 | { |
42 | 42 | return [ |
43 | - new \Twig_SimpleFilter('typogrify', [$this, 'typogrify']), |
|
44 | - new \Twig_SimpleFilter('typogrifyFeed', [$this, 'typogrifyFeed']), |
|
45 | - new \Twig_SimpleFilter('smartypants', [$this, 'smartypants']), |
|
46 | - new \Twig_SimpleFilter('truncate', [$this, 'truncate']), |
|
47 | - new \Twig_SimpleFilter('truncateOnWord', [$this, 'truncateOnWord']), |
|
48 | - new \Twig_SimpleFilter('stringy', [$this, 'stringy']), |
|
49 | - new \Twig_SimpleFilter('humanFileSize', [$this, 'humanFileSize']), |
|
50 | - new \Twig_SimpleFilter('humanDuration', [$this, 'humanDuration']), |
|
51 | - new \Twig_SimpleFilter('humanRelativeTime', [$this, 'humanRelativeTime']), |
|
52 | - new \Twig_SimpleFilter('ordinalize', [$this, 'ordinalize']), |
|
53 | - new \Twig_SimpleFilter('pluralize', [$this, 'pluralize']), |
|
54 | - new \Twig_SimpleFilter('singularize', [$this, 'singularize']), |
|
55 | - new \Twig_SimpleFilter('transliterate', [$this, 'transliterate']), |
|
56 | - new \Twig_SimpleFilter('wordLimit', [$this, 'wordLimit']), |
|
43 | + new \Twig_SimpleFilter('typogrify', [ $this, 'typogrify' ]), |
|
44 | + new \Twig_SimpleFilter('typogrifyFeed', [ $this, 'typogrifyFeed' ]), |
|
45 | + new \Twig_SimpleFilter('smartypants', [ $this, 'smartypants' ]), |
|
46 | + new \Twig_SimpleFilter('truncate', [ $this, 'truncate' ]), |
|
47 | + new \Twig_SimpleFilter('truncateOnWord', [ $this, 'truncateOnWord' ]), |
|
48 | + new \Twig_SimpleFilter('stringy', [ $this, 'stringy' ]), |
|
49 | + new \Twig_SimpleFilter('humanFileSize', [ $this, 'humanFileSize' ]), |
|
50 | + new \Twig_SimpleFilter('humanDuration', [ $this, 'humanDuration' ]), |
|
51 | + new \Twig_SimpleFilter('humanRelativeTime', [ $this, 'humanRelativeTime' ]), |
|
52 | + new \Twig_SimpleFilter('ordinalize', [ $this, 'ordinalize' ]), |
|
53 | + new \Twig_SimpleFilter('pluralize', [ $this, 'pluralize' ]), |
|
54 | + new \Twig_SimpleFilter('singularize', [ $this, 'singularize' ]), |
|
55 | + new \Twig_SimpleFilter('transliterate', [ $this, 'transliterate' ]), |
|
56 | + new \Twig_SimpleFilter('wordLimit', [ $this, 'wordLimit' ]), |
|
57 | 57 | ]; |
58 | 58 | } |
59 | 59 | |
@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | public function getFunctions() |
64 | 64 | { |
65 | 65 | return [ |
66 | - new \Twig_SimpleFunction('typogrify', [$this, 'typogrify']), |
|
67 | - new \Twig_SimpleFunction('typogrifyFeed', [$this, 'typogrifyFeed']), |
|
68 | - new \Twig_SimpleFunction('smartypants', [$this, 'smartypants']), |
|
69 | - new \Twig_SimpleFunction('getPhpTypographySettings', [$this, 'getPhpTypographySettings']), |
|
70 | - new \Twig_SimpleFunction('truncate', [$this, 'truncate']), |
|
71 | - new \Twig_SimpleFunction('truncateOnWord', [$this, 'truncateOnWord']), |
|
72 | - new \Twig_SimpleFunction('stringy', [$this, 'stringy']), |
|
73 | - new \Twig_SimpleFunction('humanFileSize', [$this, 'humanFileSize']), |
|
74 | - new \Twig_SimpleFunction('humanDuration', [$this, 'humanDuration']), |
|
75 | - new \Twig_SimpleFunction('humanRelativeTime', [$this, 'humanRelativeTime']), |
|
76 | - new \Twig_SimpleFunction('ordinalize', [$this, 'ordinalize']), |
|
77 | - new \Twig_SimpleFunction('pluralize', [$this, 'pluralize']), |
|
78 | - new \Twig_SimpleFunction('singularize', [$this, 'singularize']), |
|
79 | - new \Twig_SimpleFunction('transliterate', [$this, 'transliterate']), |
|
80 | - new \Twig_SimpleFunction('wordLimit', [$this, 'wordLimit']), |
|
66 | + new \Twig_SimpleFunction('typogrify', [ $this, 'typogrify' ]), |
|
67 | + new \Twig_SimpleFunction('typogrifyFeed', [ $this, 'typogrifyFeed' ]), |
|
68 | + new \Twig_SimpleFunction('smartypants', [ $this, 'smartypants' ]), |
|
69 | + new \Twig_SimpleFunction('getPhpTypographySettings', [ $this, 'getPhpTypographySettings' ]), |
|
70 | + new \Twig_SimpleFunction('truncate', [ $this, 'truncate' ]), |
|
71 | + new \Twig_SimpleFunction('truncateOnWord', [ $this, 'truncateOnWord' ]), |
|
72 | + new \Twig_SimpleFunction('stringy', [ $this, 'stringy' ]), |
|
73 | + new \Twig_SimpleFunction('humanFileSize', [ $this, 'humanFileSize' ]), |
|
74 | + new \Twig_SimpleFunction('humanDuration', [ $this, 'humanDuration' ]), |
|
75 | + new \Twig_SimpleFunction('humanRelativeTime', [ $this, 'humanRelativeTime' ]), |
|
76 | + new \Twig_SimpleFunction('ordinalize', [ $this, 'ordinalize' ]), |
|
77 | + new \Twig_SimpleFunction('pluralize', [ $this, 'pluralize' ]), |
|
78 | + new \Twig_SimpleFunction('singularize', [ $this, 'singularize' ]), |
|
79 | + new \Twig_SimpleFunction('transliterate', [ $this, 'transliterate' ]), |
|
80 | + new \Twig_SimpleFunction('wordLimit', [ $this, 'wordLimit' ]), |
|
81 | 81 | ]; |
82 | 82 | } |
83 | 83 |