19 declare(strict_types=1);
196 if (!is_string($from)) {
200 if (empty($this->language_key)) {
201 throw new LogicException(
"Please specify a language for the title capitalization");
204 if (!isset($this->not_capitalize[$this->language_key])) {
205 throw new LogicException(
"Language " . $this->language_key .
" is not supported for the title capitalization");
209 $to = ucwords(strtolower($from));
212 $to = preg_replace_callback_array($this->
buildPatterns($this->not_capitalize[$this->language_key]), $to);
222 return array_reduce($words,
function (array $patterns,
string $word): array {
223 $patterns[$this->
buildPattern($word)] = [ $this,
"replaceHelper" ];
234 return "/(\s|^)" . preg_quote($word,
'/') .
"(\s|$)/i";
239 return strtolower($result[0] ??
"");
replaceHelper(array $result)
trait DeriveInvokeFromTransform
buildPattern(string $word)
trait DeriveApplyToFromTransform
__construct(string $language_key)
buildPatterns(array $words)