29 public function upperCaseWords($str, $sourceSeparator =
'_', $destinationSeparator =
'_')
31 return str_replace(
' ', $destinationSeparator, ucwords(str_replace($sourceSeparator,
' ', $str)));
43 public function splitInjection($str, $length = 50, $needle =
'-', $insert =
' ')
45 $str = $this->
split($str, $length);
47 foreach ($str as $part) {
48 if ($this->
strlen($part) >= $length) {
49 $lastDelimiter = $this->
strpos($this->
strrev($part), $needle);
50 $tmpNewStr = $this->
substr($this->
strrev($part), 0, $lastDelimiter) . $insert
52 $newStr .= $this->
strrev($tmpNewStr);
75 public function split(
$value, $length = 1, $keepWords =
false, $trim =
false, $wordSeparatorRegex =
'\s')
79 if (!$strLen || !is_int($length) || $length <= 0) {
86 if (!$keepWords || $length < 2) {
87 for ($offset = 0; $offset < $strLen; $offset += $length) {
92 $split = preg_split(
'/(' . $wordSeparatorRegex .
'+)/siu',
$value,
null, PREG_SPLIT_DELIM_CAPTURE);
96 foreach ($split as $key => $part) {
113 $partLength = $this->
strlen($part);
115 if ($currentLength + $spaceLen + $partLength <= $length) {
117 }
elseif ($partLength <= $length) {
123 foreach ($this->
split($part, $length,
false, $trim, $wordSeparatorRegex) as $subPart) {
152 return mb_strlen($string, self::ICONV_CHARSET);
163 return mb_convert_encoding($string, self::ICONV_CHARSET);
174 public function substr($string, $offset, $length =
null)
177 if ($length ===
null) {
178 $length = $this->
strlen($string) - $offset;
180 return mb_substr($string, $offset, $length, self::ICONV_CHARSET);
192 $strLen = $this->
strlen($str);
196 for (
$i = $strLen - 1;
$i >= 0;
$i--) {
210 public function strpos($haystack, $needle, $offset =
null)
212 return mb_strpos($haystack, $needle, $offset, self::ICONV_CHARSET);
elseif(isset( $params[ 'redirect_parent']))
upperCaseWords($str, $sourceSeparator='_', $destinationSeparator='_')
split($value, $length=1, $keepWords=false, $trim=false, $wordSeparatorRegex='\s')
strpos($haystack, $needle, $offset=null)
splitInjection($str, $length=50, $needle='-', $insert=' ')
substr($string, $offset, $length=null)