please use here:
if (!empty($class))

;)