My experience with this issue was on 6.1.3, but i overcame this issue by replacing the battery, and over use with different iphone I've got a fair idea of what causes the battery to do this.
Some batteries have a 'memory' and I think it all depends on the kind of battery..
Much like older cellphones, if you unplugged them at half-charged, it would take a TINY amount of the total away from you. Months later, you'd go from 100% lasting 4 days, to 100% lasting 10 hours, and eventually only a few hours, when at that point you'd be heading to a shop to buy a new phone.
I can't confirm that iphones are the same, but i know for a fact that Apple has stated that the batteries have 'cycles'.. Say for example you could only get 100 charges out of an iphone.. The cycles would make it so that it unplugging it at 40% charged wouldnt count as one of those 100 charges.., but only 40% of 1 of those 100 cycles, and then running it to 20% then charging it up again.. You would have used you first cycle at 80% charged as you only had 60% left from that cycle.
If you leave your phone plugged in at 100%, and it continues to charge overnight.. The battery is constantly being drained and charged at the same time..it's using more than 1 cycle, and (back to example of 100 total cycles) effectively cutting the batteries 100(exampled) cycles to as low as only 30 cycles of full charge..
Eventually, towards the end of the batteries cycles.. at around 10cycles left, your batteries memory is so F**ked from the overcharging that it thinks that 30% is actually only 1% and shuts itself down.. later realising that that 30% might actually be 5 percent, so it turns back on and works for another while.. until you start putting battery intensive tasks to it, and it gives up again.
I hope you're following me on this..
I've tried to make it understandable through 3 years of iphones, and my own experience.
It's the same with laptops, in that it's recommended to charge them to full, then run them completely dead.. otherwise 4 months after getting laptop it needs the charger plugged in or dies straight away
Hope this helped anyone understand