private static function delimitString(string $string, string $delimiter): string
    {
        $output = [];

        if (preg_match('/\A[a-z0-9]+\z/ui', $string) && strtoupper($string) !== $string) {
            $parts = self::explodeOnCaps($string);
        } else {
            $parts = self::explodeOnDelims($string);
        }

        foreach ($parts as $part) {
            $output[] = $part.$delimiter;
        }

        return rtrim(implode('', $output), $delimiter);
    }
private static function delimitString(string $string, string $delimiter): string
    {
        $output = [];

        if (preg_match('/\A[a-z0-9]+\z/ui', $string) && strtoupper($string) !== $string) {
            $parts = self::explodeOnCaps($string);
        } else {
            $parts = self::explodeOnDelims($string);
        }

        foreach ($parts as $part) {
            $output[] = $part.$delimiter;
        }

        return rtrim(implode('', $output), $delimiter);
    }
private static function delimitString ( string $ string , string $ delimiter ) : string { $ output = [ ] ; if ( preg_match ( '/\A[a-z0-9]+\z/ui' , $ string ) && strtoupper ( $ string ) !== $ string ) { $ parts = self :: explodeOnCaps ( $ string ) ; } else { $ parts = self :: explodeOnDelims ( $ string ) ; } foreach ( $ parts as $ part ) { $ output [ ] = $ part . $ delimiter ; } return rtrim ( implode ( '' , $ output ) , $ delimiter ) ; }
Applies delimiter formatting to a string

@param string $string    The original string
@param string $delimiter The delimiter

@return string
Applies delimiter formatting to a string