curl resource referenced inside function scope instead of class scope