Horde_Imap_Client_Data_Format_String::__construct PHP Method

__construct() public method

public __construct ( $data, array $opts = [] )
$opts array Additional options: - eol: (boolean) If true, normalize EOLs in input. @since 2.2.0 - skipscan: (boolean) If true, don't scan input for binary/literal/quoted data. @since 2.2.0
    public function __construct($data, array $opts = array())
    {
        /* String data is stored in a stream. */
        $this->_data = new Horde_Stream_Temp();
        if (empty($opts['skipscan'])) {
            $this->_filter = $this->_filterParams();
            stream_filter_register('horde_imap_client_string', 'Horde_Imap_Client_Data_Format_Filter_String');
            $res = stream_filter_append($this->_data->stream, 'horde_imap_client_string', STREAM_FILTER_WRITE, $this->_filter);
        } else {
            $res = null;
        }
        if (empty($opts['eol'])) {
            $res2 = null;
        } else {
            stream_filter_register('horde_eol', 'Horde_Stream_Filter_Eol');
            $res2 = stream_filter_append($this->_data->stream, 'horde_eol', STREAM_FILTER_WRITE);
        }
        $this->_data->add($data);
        if (!is_null($res)) {
            stream_filter_remove($res);
        }
        if (!is_null($res2)) {
            stream_filter_remove($res2);
        }
        if (isset($this->_filter) && $this->_filter->nonascii && !$this instanceof Horde_Imap_Client_Data_Format_String_Support_Nonascii) {
            throw new Horde_Imap_Client_Data_Format_Exception('String contains non-ASCII characters.');
        }
    }

Usage Example

示例#1
0
文件: Nstring.php 项目: horde/horde
 /**
  */
 public function __construct($data = null)
 {
     /* Data can be null (NIL) here. */
     if (is_null($data)) {
         $this->_data = null;
     } else {
         parent::__construct($data);
     }
 }