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