I am working on Rest api end points for different content types. I am using normalizers for the same, but when i'm trying to make use of same normalizer for all content type, conditions in the functions are increasing. How can we reduce the Cyclomatic and NPath complexities. Below is example code snippet:
$appealData['description'] = !empty($entity->body->getValue()[0]['value']) ? $entity->body->getValue()[0]['value'] : '';
$appealData['image'] = !empty($imageFile) ? $imageFile->url() : '';
$appealData['pulloutQuote']['text'] = !empty($entity->field_quote_content->getValue()[0]['value']) ? $entity->field_quote_content->getValue()[0]['value'] : '';
$appealData['pulloutQuote']['author'] = !empty($entity->field_quote_citation->getValue()[0]['value']) ? $entity->field_quote_citation->getValue()[0]['value'] : '';
Any alternative to check emptiness of field value? I am just trying to replace NULL
with ''
. Please help me in this regard.