fix PHP E_NOTICE errors;
format code to adhere to PSR code style