Draw a double border around a string

@param string $string

@return string
166747
private static function __doubleBorder($string)
    {
        $border          = new Border(Border::TYPE_FRAME, '=', '#', '*');
        $borderedElement = new BorderedElement($string, $border);

        return $borderedElement->render();
    }
447343
public static function createSlug($string)
	{
		// remove all accent characters
		$string = self::remove_accents($string);

		// lowercase
		$string = strtolower($string);

		// replace all characters except letters and numbers to dashes
		$slug = preg_replace('/[^A-Za-z0-9-]+/', '-', $string);

		// deep replace double dashes
		while(strpos('--', $slug))
		{
			$slug = str_replace('--', '-', $slug);
		}

		// trim dashes at start and end
		$slug = trim($slug, '-');

		return $slug;
	}
33874
public static function strlenForUtf8($string)
	{
		$l = strlen($string);
		$p = $c = 0;
		while ($p < $l)
		{
			$a = $string[$p];
			if ($a < "\xC0")
				$p++;
			elseif ($a < "\xE0")
				$p += 2;
			elseif ($a < "\xF0")
				$p += 3;
			elseif ($a < "\xF8")
				$p += 4;
			elseif ($a < "\xFC")
				$p += 5;
			else
				$p += 6;
			$c++;
		}
		return $c;
	}
438425
public function nl2p($string)
    {
        // replace lineFeed with <br /> tag
        $lineFeed = chr(10);
        $value = preg_replace('#'.$lineFeed.'#', '<br />', $string);

        // replace double <br /> tags with </p><p> tags
        $pattern = '#<br />([ ]*)<br />#';
        $replacement = '</p><p>';
        $result = preg_replace($pattern, $replacement, $value);

        return $result;
    }
820933
public static function strlen( $string )
    {
        if ( false === ( $_encoding = static::mbSupported( $string ) ) )
        {
            return strlen( $string );
        }

        return mb_strwidth( $string, $_encoding );
    }
862035
public static function createFromString($string) {
        list($latitude, $longitude) = explode(',', $string);
        return new static(new Coordinate($latitude), new Coordinate($longitude));
    }
1336924
public function sansAccents($string = '')
    {
        $retour = "";
        $retour = str_replace(array("é", "è", "ê", "ë", "ï", "î", "â", "ä", "à", "ô", "ö", "ü", "û"), array("e", "e", "e", "e", "i", "i", "a", "a", "a", "o", "o", "u", "u"), $string);
        $retour = str_replace(array(utf8_encode("é"), utf8_encode("è"), utf8_encode("ê"), utf8_encode("ë"), utf8_encode("ï"), utf8_encode("î"), utf8_encode("â"), utf8_encode("ä"), utf8_encode("à"), utf8_encode("ô"), utf8_encode("ö"), utf8_encode("ü"), utf8_encode("û")), array("e", "e", "e", "e", "i", "i", "a", "a", "a", "o", "o", "u", "u"), $string);
        return $retour;
    }
796100
private function convertToWindowsCharset($string)
    {
        $charset = mb_detect_encoding(
            $string,
            "UTF-8, ISO-8859-1, ISO-8859-15",
            true
        );

        $string = mb_convert_encoding($string, "Windows-1252", $charset);
        return $string;
    }
335810
public function nlToPbr($string)
	{
		$string = trim($string);
		$string = Modifiers::linebreaks($string);
		$string = str_replace("\n", '<br />', $string);
		$string = str_replace('<br /><br />', "</p>\n<p>", $string);
		$string = str_replace('<p></p>', '', $string);
		return '<p>' . $string . '</p>' . PHP_EOL;
	}
332558
private static function buildUnderline($string, Border $border)
    {
        $stringLength = Util::getVisibleStringLength($string);
        $underline    = Util::buildPatternLine($border->getLineCharacter(), $stringLength);

        $result = $string . PHP_EOL . $underline . PHP_EOL;

        return $result;
    }
1075240
public function apply(string $string) : string
    {
        return str_replace($this->search, $this->replace, $string);
    }
1192622
private function createStyleFromString($string) {
        if (isset($this->styles[$string])) {
            return $this->styles[$string];
        }

        if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
            return false;
        }

        $style = new Style();
        foreach ($matches as $match) {
            array_shift($match);

            if ('fg' == $match[0]) {
                $style->setForeground($match[1]);
            }
            elseif ('bg' == $match[0]) {
                $style->setBackground($match[1]);
            }
            else {
                try {
                    $style->setOption($match[1]);
                }
                catch (\InvalidArgumentException $e) {
                    return false;
                }
            }
        }

        return $style;
    }
1340981
public static function split( $string, $width )
    {
        // str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
        // additionally, array_slice() is not enough as some character has doubled width.
        // we need a function to split string not by character count but by string width

        if ( false === ( $_encoding = static::mbSupported( $string ) ) )
        {
            return str_split( $string, $width );
        }

        $_utf8 = mb_convert_encoding( $string, 'utf8', $_encoding );
        $_lines = array();
        $_line = null;

        foreach ( preg_split( '//u', $_utf8 ) as $_character )
        {
            //  Test if $_character could be appended to current line
            if ( mb_strwidth( $_line . $_character, 'utf8' ) <= $width )
            {
                $_line .= $_character;
                continue;
            }

            //  If not, push current line to array and make new line
            $_lines[] = str_pad( $_line, $width );
            $_line = $_character;
        }

        if ( strlen( $_line ) )
        {
            $_lines[] = count( $_lines ) ? str_pad( $_line, $width ) : $_line;
        }

        mb_convert_variables( $_encoding, 'utf8', $_lines );

        return $_lines;
    }
529541
public function surround($substring) {
        $stringy = self::create($this->str, $this->encoding);
        $stringy->str = implode('', array($substring, $stringy->str, $substring));

        return $stringy;
    }
108987
public function generate($string)
    {
        if ($this->romanization === true) {
            $string = $this->romanize($string);
        }

        $string = $this->lowercase($string);
        $string = $this->removeUndesiredChars($string);
        $string = $this->trim($string);
        $string = $this->replaceWt($string);
        $string = $this->removeExtraDashes($string);

        return $string;
    }
1071615
protected function format(string $string): string
	{
		$lineWidth = $this->width - (static::PADDING * 2);

		$lines = explode(PHP_EOL, PHP_EOL . $this->wordWrap($string, $lineWidth) . PHP_EOL);

		foreach($lines as $key => $value)
		{
			$value = $this->escape($value) . str_repeat(' ', $lineWidth - mb_strlen($value));

			$lines[$key] = sprintf('%1$s%2$s%1$s', str_repeat(' ', static::PADDING), $value);
		}

		return implode(PHP_EOL, $lines);
	}
414678
public function prepare(string $string): string
    {
        foreach ($this->_steps as $step) {
            $string = $step->apply($string);
        }
        return $string;
    }