I have this:
$itemCode = $area->pickSpecificItemByType($type)->getItemCode();
It's possible that $area->pickSpecificItemByType($type)
might return null. Thus calling getItemCode()
would be impossible.
What is the cleanest and/or most efficient way to do this?
Is there any better option than this?
$itemCode = (!is_null($area->pickSpecificItemByType($type))) ?
$area->pickSpecificItemByType($type)->getItemCode() : '';