My colleague wrote some code, which is hidden behind an interface:
$myCustomValue = $customer->getCustomAttribute('my_custom_attribute')->getValue();
Working on integrations now, I invoke his code via an API and just came across customers who do not have a value set for that attribute.
The error message I get is:
Call to a member function getValue() on null
How can I modify his code best, so that it checks first if the value is set for the specific customer?
$myCustomValue = $customer->getCustomAttribute('my_custom_attribute');
$customer->getData('my_custom_attribute');