fix PHP E_NOTICE errors

fix PHP E_NOTICE errors, change constructor to PHP5 style, format code to adhere to PSR