1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-12 16:24:00 +02:00

titleize refactoring to avoid visibility problems in PHP 5.3

This commit is contained in:
gotterdemarung
2013-12-10 22:59:10 +02:00
parent 3458fd79fd
commit 5e01d895db

View File

@@ -217,21 +217,22 @@ class Stringy
*/ */
public function titleize($ignore = null) public function titleize($ignore = null)
{ {
$stringy = self::create($this->str, $this->encoding)->trim(); $buffer = $this->trim();
$encoding = $stringy->encoding; $encoding = $this->encoding;
$stringy->str = preg_replace_callback( $buffer = preg_replace_callback(
'/([\S]+)/u', '/([\S]+)/u',
function ($match) use (&$encoding, &$ignore, &$stringy) { function ($match) use (&$encoding, &$ignore) {
if ($ignore && in_array($match[0], $ignore)) if ($ignore && in_array($match[0], $ignore)) {
return $match[0]; return $match[0];
$stringy->str = $match[0]; } else {
return $stringy->upperCaseFirst(); return (string) (new Stringy($match[0], $encoding))->upperCaseFirst();
}
}, },
$stringy->str $buffer
); );
return $stringy; return new Stringy($buffer, $encoding);
} }
/** /**