Fix PHP Fatal from unchecked getStorage()

Additionally implemented a slightly more optimized approach.
Polished pull request as requested

Fixed formatting and removed a left over commented echo
Merge pull request #813 from itheiss/master

Fix PHP Fatal from unchecked getStorage()