NastyCode.php
public static function encode(String $string, $badWords = NULL, $changeChar = '[badchars]') : String
    {
        if( empty($badWords) )
        {
            $secnc      = Properties::$ncEncode;
            $badWords   = $secnc['badChars'];
            $changeChar = $secnc['changeBadChars'];
        }

        $regex = Singleton::class('ZN\Regex');

        if( ! is_array($badWords) )
        {
            return $string = $regex->replace($badWords, $changeChar, $string, 'xi');
        }

        $ch = '';
        $i  = 0;

        foreach( $badWords as $value )
        {
            if( ! is_array($changeChar) )
            {
                $ch = $changeChar;
            }
            else
            {
                if( isset($changeChar[$i]) )
                {
                    $ch = $changeChar[$i];
                    $i++;
                }
            }

            $string = $regex->replace($value, $ch, $string, 'xi');
        }

        return $string;
    }
public static function encode(String $string, $badWords = NULL, $changeChar = '[badchars]') : String
    {
        if( empty($badWords) )
        {
            $secnc      = Properties::$ncEncode;
            $badWords   = $secnc['badChars'];
            $changeChar = $secnc['changeBadChars'];
        }

        $regex = Singleton::class('ZN\Regex');

        if( ! is_array($badWords) )
        {
            return $string = $regex->replace($badWords, $changeChar, $string, 'xi');
        }

        $ch = '';
        $i  = 0;

        foreach( $badWords as $value )
        {
            if( ! is_array($changeChar) )
            {
                $ch = $changeChar;
            }
            else
            {
                if( isset($changeChar[$i]) )
                {
                    $ch = $changeChar[$i];
                    $i++;
                }
            }

            $string = $regex->replace($value, $ch, $string, 'xi');
        }

        return $string;
    }
public static function encode ( String $ string , $ badWords = NULL , $ changeChar = '[badchars]' ) : String { if ( empty ( $ badWords ) ) { $ secnc = Properties :: $ ncEncode ; $ badWords = $ secnc [ 'badChars' ] ; $ changeChar = $ secnc [ 'changeBadChars' ] ; } $ regex = Singleton :: class ( 'ZN\Regex' ) ; if ( ! is_array ( $ badWords ) ) { return $ string = $ regex -> replace ( $ badWords , $ changeChar , $ string , 'xi' ) ; } $ ch = '' ; $ i = 0 ; foreach ( $ badWords as $ value ) { if ( ! is_array ( $ changeChar ) ) { $ ch = $ changeChar ; } else { if ( isset ( $ changeChar [ $ i ] ) ) { $ ch = $ changeChar [ $ i ] ; $ i ++ ; } } $ string = $ regex -> replace ( $ value , $ ch , $ string , 'xi' ) ; } return $ string ; }
Encode Nasty Code

@param string $string
@param mixed  $badWords   = NULL
@param mixed  $changeChar = '[badchars]'

@return string
Encode Nasty Code