Moving functionality to PSR-2

I've been working today on upgrading the library to PSR-2 compliance (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). I've gone through the code and mostly changed bits of formatting, standardised usage of namespaces, eliminated tiny bits of duplication.

All unit tests pass, and smoketest does too - phew!