Returns a masked string where only the last n characters are visible.

@param  string $string  String to mask
@param  int    $visible Number of characters to show
@param  string $mask    Character used to replace remaining characters
@return string
347380
public static function mask(string $string, int $visible = 3, string $mask = '*'): string
	{
		if($visible === 0)
		{
			return str_repeat($mask, mb_strlen($string));
		}

		$visible = mb_substr($string, -$visible);

		return str_pad($visible, (mb_strlen($string) + (strlen($visible) - mb_strlen($visible))), $mask, STR_PAD_LEFT);
	}
702813
public static function clearString( string $string ) {
		$string = trim( $string );
		$string = stripslashes( $string );
		$string = htmlspecialchars( $string );

		return $string;
	}
962538
private function stripAccents($string){
		$string = utf8_decode($string);
		$string = strtr($string,
						utf8_decode('Ã Ã¡Ã¢Ã£Ã¤Ã§Ã¨Ã©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã±Ã²Ã³Ã´ÃµÃ¶Ã¹ÃºÃ»Ã¼Ã½Ã¿Ã€Ã�Ã‚ÃƒÃ„Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃ�ÃŽÃ�Ã‘Ã’Ã“Ã”Ã•Ã–Ã™ÃšÃ›ÃœÃ�'),
						'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
		return utf8_encode($string);
	}
717886
public function wordWrap($string, $width = 75, $break = "\n", $cut = false)
    {
        $string = (string) $string;
        if ($string === '') {
            return '';
        }

        $break = (string) $break;
        if ($break === '') {
            throw new Exception\InvalidArgumentException('Break string cannot be empty');
        }

        $width = (int) $width;
        if ($width === 0 && $cut) {
            throw new Exception\InvalidArgumentException('Cannot force cut when width is zero');
        }

        if (StringUtils::isSingleByteEncoding($this->getEncoding())) {
            return wordwrap($string, $width, $break, $cut);
        }

        $stringWidth = $this->strlen($string);
        $breakWidth  = $this->strlen($break);

        $result    = '';
        $lastStart = $lastSpace = 0;

        for ($current = 0; $current < $stringWidth; $current++) {
            $char = $this->substr($string, $current, 1);

            $possibleBreak = $char;
            if ($breakWidth !== 1) {
                $possibleBreak = $this->substr($string, $current, $breakWidth);
            }

            if ($possibleBreak === $break) {
                $result    .= $this->substr($string, $lastStart, $current - $lastStart + $breakWidth);
                $current   += $breakWidth - 1;
                $lastStart  = $lastSpace = $current + 1;
                continue;
            }

            if ($char === ' ') {
                if ($current - $lastStart >= $width) {
                    $result    .= $this->substr($string, $lastStart, $current - $lastStart) . $break;
                    $lastStart  = $current + 1;
                }

                $lastSpace = $current;
                continue;
            }

            if ($current - $lastStart >= $width && $cut && $lastStart >= $lastSpace) {
                $result    .= $this->substr($string, $lastStart, $current - $lastStart) . $break;
                $lastStart  = $lastSpace = $current;
                continue;
            }

            if ($current - $lastStart >= $width && $lastStart < $lastSpace) {
                $result    .= $this->substr($string, $lastStart, $lastSpace - $lastStart) . $break;
                $lastStart  = $lastSpace = $lastSpace + 1;
                continue;
            }
        }

        if ($lastStart !== $current) {
            $result .= $this->substr($string, $lastStart, $current - $lastStart);
        }

        return $result;
    }
1064774
public function removeHidden($hidden)
	{
		if (is_string($hidden)) {
			$hidden = func_get_args();
		}

		$this->hidden = array_diff($this->hidden, $hidden);

		return $this;
	}
1164982
protected function evaluateDateString($string)
    {
        $seconds = 1;
        $matches = [];
        preg_match('/^([0-9]*)([s|M|h|d|m|y])$/', $string, $matches);

        switch ($matches[2]) {
            case 's':
                $seconds = $matches[1];
                break;
            case 'M':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 's');
                break;
            case 'h':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 'M');
                break;
            case 'd':
                $seconds = $this->evaluateDateString(24 * $matches[1] . 'h');
                break;
            case 'm':
                $seconds = $this->evaluateDateString(30 * $matches[1] . 'd');
                break;
            case 'y':
                $seconds = $this->evaluateDateString(12 * $matches[1] . 'm');
                break;
        }

        return $seconds;
    }
408319
public function eatCSpan($mask, $maxLength = null)
    {
        if (null === $maxLength) {
            $maxLength = $this->getRemainingByteCount();
        }

        return $this->read(strcspn($this->data, $mask, $this->offset, $maxLength));
    }
1134477
public static function getStringWithoutLastElement($string, $separator)
    {
        $elements = self::getStringElements($string, $separator);
        $lastKey = Arrays::getLastKey($elements);

        unset($elements[$lastKey]);

        return implode($separator, $elements);
    }
546365
public function cleanNewlines($string) {
        if ($max = $this->getConfig('maxNewlines')) {
            $string = preg_replace('/\n{' . ($max + 1) . ',}/', str_repeat("\n", $max), $string);
        }

        return trim($string);
    }
757331
public static function last($string, $length = 1, $encoding = null)
    {
        if ($string === '' || $length <= 0) {
            return '';
        }

        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        return Mbstring::substr($string, -$length, null, $encoding);
    }
583903
public function replace(string $text, string $mask = '*'): string
    {
        $found = $this->search($text);

        $replace = [];
        foreach ($found as $v) {
            $replace[$v['word']] = $mask;
        }

        return \strtr($text, $replace);
    }
470290
protected static function unreadableString($string)
	{
		$arrString['special'] = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞß@àáâãäåæç&èéêëìíîïðñòóôõöøùúûýýþÿ$°ºª';
		$arrString['number']  = '0123456789';
		$unreadable = $arrString['special'] . $arrString['number'];

		$arrString['string']  = 'aaaaaaaceeeeiiiidnoooooouuuuuybbaaaaaaaaceeeeeiiiidnoooooouuuyybysooa';
		$arrString['letters'] = 'oizeasbtbg';
		$readable = $arrString['string'] . $arrString['letters'];

		$string = strtr(utf8_decode($string), utf8_decode($unreadable), $readable);

        return strtolower(utf8_encode($string));
	}
977931
public static function applyMask($text, $mask)
    {
        $length = strlen($text);
        $buff = '';

        $special = array('/', '.', '-', '_', ' ');

        for ($i = 0, $j = 0; $i < $length; $i++, $j++) {
            if (!isset($text[$i]) || !isset($mask[$j])) {
                break;
            }

            if (in_array($mask[$j], $special)) {
                $buff .= $mask[$j];
                $j++;
            }

            $buff .= $text[$i];
        }

        return $buff;
    }
1231460
private function stringToNum(string $string) : BigNumber
    {
        $number = new BigNumber(0);
        foreach (str_split(strrev($string)) as $char) {
            $number->multiply($this->alphabetLength)->add(array_search($char, $this->alphabet, false));
        }

        return $number;
    }
1205768
public function pegaPosStringDeterminada($string, $stringBusca)
    {
        $tamanhoStrBusca = strlen($stringBusca);
     
        return stripos($string, $stringBusca) + $tamanhoStrBusca + 1;
    }
768875
public static function substring($string, $from, $to) {
    return mb_substr($string, $from, abs($from-$to));
  }
736729
private function processWildcard(&$string)
    {
        if (false === $strpos = strpos($string, '*')) {
            return false;
        }

        $escapeChars = 0;
        while (isset($string[--$strpos]) && $string[$strpos] === '\\') {
            $escapeChars++;
        }


        $isEscaped = $escapeChars % 2 !== 0;

        // remove one of the escaping characters
        if ($isEscaped) {
            $string = substr($string, 0, $strpos - 1) . substr($string, $strpos);
        }

        return !$isEscaped;
    }