You are here

public static function WebformMultiple::isEmpty in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Element/WebformMultiple.php \Drupal\webform\Element\WebformMultiple::isEmpty()

Check if array is empty.

Parameters

string|array $value: An item.

Return value

bool FALSE if item is an empty string or an empty array.

2 calls to WebformMultiple::isEmpty()
WebformMultiple::convertValuesToItems in src/Element/WebformMultiple.php
Convert an array containing of values (elements or _item_ and weight) to an array of items.
WebformMultiple::validateUniqueKeys in src/Element/WebformMultiple.php
Validate composite element has unique keys.

File

src/Element/WebformMultiple.php, line 1091

Class

WebformMultiple
Provides a webform element to assist in creation of multiple elements.

Namespace

Drupal\webform\Element

Code

public static function isEmpty($value = NULL) {
  if (is_null($value)) {
    return TRUE;
  }
  elseif (is_string($value)) {
    return $value === '' ? TRUE : FALSE;
  }
  elseif (is_array($value)) {
    return !array_filter($value, function ($item) {
      return !static::isEmpty($item);
    });
  }
  else {
    return FALSE;
  }
}