Is there any way to reduce this bit of Mathf.Clamp code for spawn positions down to one line?

I have a fairly basic stage set up where the players are spawned on the opposite side around natural zero of the world - they end up in positive / negative positions. I would like to clamp them so that neither can leave the 2D playing field. At current, I have that accomplished by using this snippet:

    Vector3 SpawnClamp = _transform.position;
    // Positive
    if (PlayerIDNumber == 0)
    {
        SpawnClamp.x = Mathf.Clamp(SpawnClamp.x, SpawnPosition.x, -SpawnPosition.x);
    }

    // Negative 
    if (PlayerIDNumber == 1)
    {
        SpawnClamp.x = Mathf.Clamp(SpawnClamp.x, -SpawnPosition.x, SpawnPosition.x);
    }

However, it feels like there must be a simpler way to do this without repeating the line twice. I would rather reduce it down to one or two lines of code - if it is at all possible. Can that be done?

If you only have two player IDs you could use a ternary operator

Vector3 SpawnClamp = transform.position;

float _spawnPos = (PlayerIDNumber == 0)? SpawnPosition.x : -SpawnPosition.x;
		
SpawnClamp.x = Mathf.Clamp(SpawnClamp.x, _spawnPos, -_spawnPos);