An extension of the Newman–Janis algorithm