As others have mentioned, your tabbing has quite the negative impact on readability.
As dusty stated, you can safely declare $collection as private.
There is no reason to check if the $collected class object is declared or if the designated $key exists before pushing an element into it. Just push that sucker in there!
In captureShutdown() method there is ...
"been occurred" is grammatically incorrect, and I don't think this line makes any sense:
if (ini_get('display_errors') || php_sapi_name() === 'cli')
php_sapi_name() will always return either a 1 or a 0, depending on what method the server is using to access the php script[internally]. It has nothing to do with client side whether you are in development or ...
To me you're kind of handling the exception in two ways:
you are acting like a library in the sense that you talk about an exception to be raised;
you are acting like an application in the sense that you print out error messages and then continue running.
I think you are mainly having the script / function be used as a library, as you return the matrix ...
Your assumption is right: the logging library should cover your needs. I use it in every script.
Here is some semi-borrowed code that I use in some scripts:
# define logging options
logger = logging.getLogger(__name__)
# create a file handler
handler = logging.FileHandler(current_dir + log_file)
The Python community favors having just one way to do something. As the Zen of Python puts it:
There should be one-- and preferably only one --obvious way to do it.
Other people and packages will be using the logging module, in general. That makes it much easier for your code to interoperate with other packages, use consistent configuration, avoid non-...
Yes logging could replace writeReport, but it wouldn't write JSON. It would not be able to replace the other two functions.
But logging is a complex library, and can be rather daunting to get it to work correctly as a beginner. And overall the majority of your code would still be the same. Given that you're mutating globals than I think you may be ...