worried about my depo shot

so I've been on the depo shot for 2 years now and I'm starting to get worried. Someone recently told me that it's not meant to be taken for more than 2 years and if you do then it'll hurt your ability to get pregnant at all when your ready. But my doctor told me that I'll be able to have children once I stop the depo shot and it won't affect it in any way. So which one is it??? I want to be able to have children once I'm ready