From 5e01d895dba36af7bc4923a4a40773ccdb510e57 Mon Sep 17 00:00:00 2001 From: gotterdemarung Date: Tue, 10 Dec 2013 22:59:10 +0200 Subject: [PATCH] titleize refactoring to avoid visibility problems in PHP 5.3 --- src/Stringy/Stringy.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Stringy/Stringy.php b/src/Stringy/Stringy.php index 888f721..3e0a408 100644 --- a/src/Stringy/Stringy.php +++ b/src/Stringy/Stringy.php @@ -217,21 +217,22 @@ class Stringy */ public function titleize($ignore = null) { - $stringy = self::create($this->str, $this->encoding)->trim(); - $encoding = $stringy->encoding; + $buffer = $this->trim(); + $encoding = $this->encoding; - $stringy->str = preg_replace_callback( + $buffer = preg_replace_callback( '/([\S]+)/u', - function ($match) use (&$encoding, &$ignore, &$stringy) { - if ($ignore && in_array($match[0], $ignore)) + function ($match) use (&$encoding, &$ignore) { + if ($ignore && in_array($match[0], $ignore)) { return $match[0]; - $stringy->str = $match[0]; - return $stringy->upperCaseFirst(); + } else { + return (string) (new Stringy($match[0], $encoding))->upperCaseFirst(); + } }, - $stringy->str + $buffer ); - return $stringy; + return new Stringy($buffer, $encoding); } /**