Validate a class before using it

Validate a class before using it in WC_Shipping and WC_Payment_Gatewats.