3 declare(strict_types=1);
197 if (!is_string($from)) {
201 if (empty($this->language_key)) {
202 throw new LogicException(
"Please specify a language for the title capitalization");
205 if (!isset($this->not_capitalize[$this->language_key])) {
206 throw new LogicException(
"Language " . $this->language_key .
" is not supported for the title capitalization");
210 $to = ucwords(strtolower($from));
213 $to = preg_replace_callback_array($this->
buildPatterns($this->not_capitalize[$this->language_key]), $to);
223 return array_reduce($words,
function (array $patterns,
string $word): array {
224 $patterns[$this->
buildPattern($word)] = [ $this,
"replaceHelper" ];
235 return "/(\s|^)" . preg_quote($word,
'/') .
"(\s|$)/i";
240 return strtolower($result[0] ??
"");
replaceHelper(array $result)
buildPattern(string $word)
trait DeriveApplyToFromTransform
trait DeriveInvokeFromTransform
__construct(string $language_key)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildPatterns(array $words)