@@ -75,21 +75,21 @@ |
||
75 | 75 | * @return string the shortend text |
76 | 76 | * @throws \ErrorException |
77 | 77 | */ |
78 | - public function getExcerpt(string $text, int $count=Constant::EXCERPT_WORD_COUNT){ |
|
79 | - if($count < 1){ |
|
78 | + public function getExcerpt(string $text, int $count = Constant::EXCERPT_WORD_COUNT) { |
|
79 | + if ($count < 1) { |
|
80 | 80 | throw new \ErrorException('excerpt length too low'); |
81 | 81 | } |
82 | 82 | |
83 | 83 | $text = str_replace(" ", " ", $text); |
84 | 84 | $string = explode(" ", $text); |
85 | - if(count($string) <= $count){ |
|
85 | + if (count($string) <= $count) { |
|
86 | 86 | return $text; |
87 | 87 | } |
88 | 88 | $trimed = ''; |
89 | - for ( $wordCounter = 0; $wordCounter < $count; $wordCounter++ ){ |
|
89 | + for ($wordCounter = 0; $wordCounter < $count; $wordCounter++) { |
|
90 | 90 | //TODO Take into account the "read more" tag |
91 | 91 | $trimed .= $string[$wordCounter]; |
92 | - if ( $wordCounter < $count-1 ){ $trimed .= " "; } |
|
92 | + if ($wordCounter < $count - 1) { $trimed .= " "; } |
|
93 | 93 | else { $trimed .= "..."; } |
94 | 94 | } |
95 | 95 | $trimed = trim($trimed); |
@@ -89,8 +89,7 @@ |
||
89 | 89 | for ( $wordCounter = 0; $wordCounter < $count; $wordCounter++ ){ |
90 | 90 | //TODO Take into account the "read more" tag |
91 | 91 | $trimed .= $string[$wordCounter]; |
92 | - if ( $wordCounter < $count-1 ){ $trimed .= " "; } |
|
93 | - else { $trimed .= "..."; } |
|
92 | + if ( $wordCounter < $count-1 ){ $trimed .= " "; } else { $trimed .= "..."; } |
|
94 | 93 | } |
95 | 94 | $trimed = trim($trimed); |
96 | 95 | return $trimed; |