Commit a2406c01 by Taylor Otwell

Trim comment bloat in Text class.

parent 5755fdab
...@@ -17,15 +17,8 @@ class Text { ...@@ -17,15 +17,8 @@ class Text {
return $value; return $value;
} }
// -----------------------------------------------------
// Limit the words in the string.
// -----------------------------------------------------
preg_match('/^\s*+(?:\S++\s*+){1,'.$limit.'}/', $value, $matches); preg_match('/^\s*+(?:\S++\s*+){1,'.$limit.'}/', $value, $matches);
// -----------------------------------------------------
// If the string did not exceed the limit, we won't
// need an ending character.
// -----------------------------------------------------
if (strlen($value) == strlen($matches[0])) if (strlen($value) == strlen($matches[0]))
{ {
$end = ''; $end = '';
...@@ -49,9 +42,7 @@ class Text { ...@@ -49,9 +42,7 @@ class Text {
return $value; return $value;
} }
// -----------------------------------------------------
// Replace new lines and whitespace in the string. // Replace new lines and whitespace in the string.
// -----------------------------------------------------
$value = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $value)); $value = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $value));
if (strlen($value) <= $limit) if (strlen($value) <= $limit)
...@@ -61,10 +52,6 @@ class Text { ...@@ -61,10 +52,6 @@ class Text {
$out = ''; $out = '';
// -----------------------------------------------------
// The string exceeds the character limit. Add each word
// to the output individually until we reach the limit.
// -----------------------------------------------------
foreach (explode(' ', trim($value)) as $val) foreach (explode(' ', trim($value)) as $val)
{ {
$out .= $val.' '; $out .= $val.' ';
...@@ -90,14 +77,9 @@ class Text { ...@@ -90,14 +77,9 @@ class Text {
{ {
$value = ' '.$value.' '; $value = ' '.$value.' ';
// -----------------------------------------------------
// Assume the word will be book-ended by the following. // Assume the word will be book-ended by the following.
// -----------------------------------------------------
$delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]'; $delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
// -----------------------------------------------------
// Replace the censored words.
// -----------------------------------------------------
foreach ($censored as $word) foreach ($censored as $word)
{ {
if ($replacement != '') if ($replacement != '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment