class drush_outputformat_string

  1. 8.0.x commands/core/outputformat/string.inc drush_outputformat_string
  2. 6.x commands/core/outputformat/string.inc drush_outputformat_string
  3. 7.x commands/core/outputformat/string.inc drush_outputformat_string
  4. master commands/core/outputformat/string.inc drush_outputformat_string

Output formatter 'string'

Hierarchy

Expanded class hierarchy of drush_outputformat_string

Members

File

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

View source
class drush_outputformat_string extends drush_outputformat {
  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;
  }
}