Cyclomatic complexity

http://jenkins.buttonweavers.com:8080/job/buttonmen-blackshadowshade/51/

Many of the PHPMD warnings have been dealt with in this pull request (see #417).

There are many rather large refactorings here, touching almost all of the PHP code, so it's possible that something subtle will be broken.

The PHP file audit fails now because BMAttack has no classes. However, it has an abstract class. Can we change the audit please to allow this?