Returns prefix and suffix of a specified string.

@param  string $string
@return string
337029
protected function prefixSuffix($string)
    {
        $prefix = ltrim($string) !== $string ? ' ' : '';

        $suffix = rtrim($string) !== $string ? ' ' : '';

        return (array) array($prefix, $suffix);
    }
812997
public function suffix($string, $in_place = false)
    {
        $suffixed = array_map(function ($value) use ($string) {
            return $value . $string;
        }, $this->list);

        if ($in_place) {
            $this->list = $suffixed;

            return $this;
        }

        return new ItemList($suffixed);
    }
306477
public static function rstrip($str, $suffix)
    {
        if (substr($str, -strlen($suffix)) == $suffix) {
            return substr($str, 0, -strlen($suffix));
        }
        return $str;
    }
729442
public static function tags(string $string): string
    {
        $string = str_replace('<', '&lt;', $string);
        $string = str_replace('>', '&gt;', $string);
        return $string;
    }
198864
public static function alias($string)
    {
        $cleaned = self::strip($string);
        $cleaned = Str::slug($cleaned);

        return $cleaned;
    }
844342
public function normalize(string $string) : string
    {
        if (isset($this->cache[$string])) {
            return $this->cache[$string];
        }

        $result = $this->normalizeChain($string);

        $toCache = array_map(function(RuleInterface $rule) use (&$result) {
            return $result = $rule->apply($result);
        }, $this->rules);

        // Add cache for variants
        array_map(function($index) use ($result) {
            $this->cache[$index] = $result;
        }, $toCache);
        $this->cache[$string] = $result;

        return $result;
    }
1226147
protected function getEol( $string ) {
		$pattern = '~[\s\S]*?([\r\n]+)[\s\S]*~m';
		$eol = preg_replace( $pattern, '$1', $string );
		return strlen( $eol ) > 0 ? $eol : PHP_EOL;
	}
225285
public static function underscore( $string ) {

        if ( !preg_match( '/[A-Z-]|::/' , $string ) ) return $string;

        $string = strtr( $string , [ '::' => '/' , '-' => '_' ] );

        $string = preg_replace( '/([A-Z\d]+)([A-Z][a-z])/' , '$1_$2' , $string );

        $string = preg_replace( '/([a-z\d])([A-Z])/' , '$1_$2' , $string );

        return strtolower( $string );

    }
261118
public static function strip($string)
    {
        $cleaned = strip_tags($string);
        $cleaned = Str::trim($cleaned);

        return $cleaned;
    }
743836
public function getTidy($string)
    {
        if (class_exists('Tidy')) {
            if (!$this->_tidy) {
                $this->_tidy = new Tidy();
            }

            $this->_tidy->parseString($string, $this->_config, $this->_encoding);
        }

        return $this->_tidy;
    }
86180
public static function encode($string)
    {
        if (is_array($string)) {
            foreach ($string as $k => $substring) {
                $string[$k] = static::encode($substring);
            }
        } else {
            $string = urlencode($string);
        }

        return $string;
    }
57164
public function normalize($string) {
		$string = $this->_normalize($string, ['clean' => true, 'case' => true]);
		return implode('-', str_split($string, $this->_partLength));
	}
216281
protected function buildPrefix(array $strings)
	{
		$prefix = [];
		foreach ($strings as $string)
		{
			// Remove the last element (suffix) of each string before adding it
			array_pop($string);
			$prefix[] = $string;
		}

		return $prefix;
	}
1182013
public static function removeSuffix($string, $suffix)
    {
        if (self::endsWith($string, $suffix)) {
            return mb_substr($string, 0, -mb_strlen($suffix));
        }
        return $string;
    }
959065
protected function replace($string)
    {
        foreach ($this->patterns as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
1292472
public function trim( $string, $limit = 80, $suffix = '&hellip;' ) {
		if ( $limit < mb_strlen( $string, 'utf-8' ) ) {
			$string = mb_substr( $string, 0, $limit - 1 ) . $suffix;
		}

		return $string;
	}
1107857
public function getThemedLink($string)
    {
        $search = preg_grep('/\b' . preg_quote($string, '/') . '\b/', $this->words);
        return $search[array_rand($search)];
    }