function drush_outputformat_string::format

8.0.x string.inc drush_outputformat_string::format($data, $metadata)
6.x string.inc drush_outputformat_string::format($data, $metadata)
7.x string.inc drush_outputformat_string::format($data, $metadata)
master string.inc drush_outputformat_string::format($data, $metadata)

Overrides drush_outputformat::format

File

commands/core/outputformat/string.inc, line 22

Class

drush_outputformat_string
Output formatter 'string'

Code

function format($data, $metadata) {
  // If the data is an array, print the value of the first item.
  if (is_array($data)) {
    if (count($data) > 1) {
      return $this->format_error("Multiple rows provided where only one is allowed.");
    }
    if (!empty($data)) {
      $data = reset($data);
    }
    if (is_array($data)) {
      return $this->format_error("Array provided where a string is required.");
    }
  }
  return (string) $data;
}