public static function finish($value, $cap)
    {
        $quoted = preg_quote($cap, '/');

        return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
    }
public static function finish($value, $cap)
    {
        $quoted = preg_quote($cap, '/');

        return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
    }
public static function finish ( $ value , $ cap ) { $ quoted = preg_quote ( $ cap , '/' ) ; return preg_replace ( '/(?:' . $ quoted . ')+$/u' , '' , $ value ) . $ cap ; }
Cap a string with a single instance of a given value.

@param  string  $value
@param  string  $cap
@return string
Cap a string with a single instance of a given value .