check if string is empty drupal 8 code example
Example: get if drupal 8 field is empty
if (!$entity->get('category')->isEmpty()) {
/** @var EntityInterface $category */
$category = $entity->get('category')->entity;
$row['category']['data'] = [
'#type' => 'link',
'#title' => $category->get('name')->value,
'#url' => $category->toUrl(),
];
}
else {
$row['category'] = NULL;
}