PSR-2 code style

This commit adapts the code style according to the recommendations of
[PSR-2](http://www.php-fig.org/psr/psr-2/) and adds PHPDoc annotations for documentation purposes.
`preg_match` returns `0` when the pattern does not match and `false` when an error occured - we want to catch both cases.