3 declare(strict_types=1);
203 if (!is_string($from)) {
207 if (empty($this->language_key)) {
208 throw new LogicException(
"Please specify a language for the title capitalization");
211 if (!isset($this->not_capitalize[$this->language_key])) {
212 throw new LogicException(
"Language " . $this->language_key .
" is not supported for the title capitalization");
216 $to = ucwords(strtolower($from));
219 $to = preg_replace_callback_array($this->
buildPatterns($this->not_capitalize[$this->language_key]), $to);
234 return array_reduce($words,
function (array $patterns,
string $word) : array {
235 $patterns[$this->
buildPattern($word)] = [ $this,
"replaceHelper" ];
252 return "/(\s|^)" . preg_quote($word) .
"(\s|$)/i";
263 return strtolower($result[0] ??
"");
replaceHelper(array $result)
buildPattern(string $word)
trait DeriveApplyToFromTransform
trait DeriveInvokeFromTransform
__construct(string $language_key, Factory $factory)
CaseOfLabel constructor.
buildPatterns(array $words)