go-arbitrary/t_phonenumber_egypt_3_4.go

53 lines
1.0 KiB
Go
Raw Normal View History

2021-11-22 16:48:48 +00:00
package arbitrary
import (
"fmt"
2021-11-22 16:56:28 +00:00
"strings"
2021-11-22 16:48:48 +00:00
)
func (arb T) phonenumber_egypt_3_4(areacode string) string {
var localpart1 int
{
localpart1 = arb.randomness.Intn(1000)
}
var localpart2 int
{
localpart2 = arb.randomness.Intn(10000)
}
var format string
{
var formats []string = []string{
"0%s-%03d-%04d",
"+20-%s-%03d-%04d",
}
format = formats[arb.randomness.Intn(len(formats))]
}
var result string
{
result = fmt.Sprintf(format, areacode, localpart1, localpart2)
}
2021-11-22 16:56:28 +00:00
{
if 0 == arb.randomness.Intn(4) {
result = strings.ReplaceAll(result, "0", "٠")
result = strings.ReplaceAll(result, "1", "١")
result = strings.ReplaceAll(result, "2", "٢")
result = strings.ReplaceAll(result, "3", "٣")
result = strings.ReplaceAll(result, "4", "٤")
result = strings.ReplaceAll(result, "5", "٥")
result = strings.ReplaceAll(result, "6", "٦")
result = strings.ReplaceAll(result, "7", "٧")
result = strings.ReplaceAll(result, "8", "٨")
result = strings.ReplaceAll(result, "9", "٩")
}
}
2021-11-22 16:48:48 +00:00
return result
}