Psr code standard

Code formatted to PSR-2 standard.

There are some parts that haven't been changed, and that's due to function signatures and class names etc.

I will run a report on what's outstanding to see where we can take it.