Doping dependence of the magnetic excitations in La$_{2-x}$Sr$_x$CuO$_4$