mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-12 00:04:11 +02:00
titleize refactoring to avoid visibility problems in PHP 5.3
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user