Simple rotation/eulerangles question

Dear Forum,
Question: What’s the best approach to have a game object rotate to a certain direction and once it hits a position along the rotation line it rotates to the opposite direction. Here’s some unfinished code of what I’m attempting to achieve.

if (transform.eulerAngles.z >= 10  transform.eulerAngles.z <= 14) // rotate right
transform.Rotate(-Vector3.forward, Time.deltaTime * 10);

if (transform.eulerAngles.z >= 340  transform.eulerAngles.z <= 345 ) //rotate left
transform.Rotate(Vector3.forward, Time.deltaTime * 10);

Many Thanks in advance.

As with most things, there are a few ways to do this. Quaternion.Lerp (or Slerp) will give you an nice interpolation between TO and FROM rotations. Alternatively, you could Mathf.PingPong between set rotation values and do it that way within an Update loop.