improve readability of code

* coding style fixes
* some PHPStorm code inspection fixes
* few method extractions
* removed unused methods
* whitespace fixes

 all as part of our code cleanup strategy and to make code better readable.
As we talk about here:
https://github.com/piwik/piwik/issues/6184
Put @ to hide error messages is a bad pratice, you should better handle errors you know to be able to happen and let others appear to debug them.

If you get an error because the file does not exist, do not hide the error but test if the file exists (with file_exists) before execute the function.