Call to a member function getCode() on null