Horde_Imap_Client_Data_Fetch::_msgText PHP Method

_msgText() protected method

Return text representation of a field.
protected _msgText ( boolean $stream, mixed $data ) : mixed
$stream boolean Return as a stream?
$data mixed The field data (string or resource) or null if field does not exist.
return mixed Requested text representation.
    protected function _msgText($stream, $data)
    {
        if ($data instanceof Horde_Stream) {
            if ($stream) {
                $data->rewind();
                return $data->stream;
            }
            return strval($data);
        }
        if (is_resource($data)) {
            rewind($data);
            return $stream ? $data : stream_get_contents($data);
        }
        if (!$stream) {
            return strval($data);
        }
        $tmp = fopen('php://temp', 'w+');
        if (!is_null($data)) {
            fwrite($tmp, $data);
            rewind($tmp);
        }
        return $tmp;
    }