<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="mongodb-bson-binary.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>MongoDB\BSON\Binary::__construct</refname>
  <refpurpose>Construct a new Binary</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>final</modifier> <modifier>public</modifier> <methodname>MongoDB\BSON\Binary::__construct</methodname>
   <methodparam><type>string</type><parameter>data</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>type</parameter><initializer>MongoDB\BSON\Binary::TYPE_GENERIC</initializer></methodparam>
  </methodsynopsis>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>data</parameter> (<type>string</type>)</term>
    <listitem>
     <para>
      Binary data.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>type</parameter> (<type>int</type>)</term>
    <listitem>
     <para>
      Unsigned 8-bit integer denoting the data&apos;s type. Defaults to <constant>MongoDB\BSON\Binary::TYPE_GENERIC</constant> if not specified.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <simplelist>
   &mongodb.throws.argumentparsing;
   <member>Throws <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname> if <parameter>type</parameter> is not an unsigned 8-bit integer.</member>
   <member>Throws <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname> if <parameter>type</parameter> is <constant>MongoDB\BSON\Binary::TYPE_UUID</constant> or <constant>MongoDB\BSON\Binary::TYPE_OLD_UUID</constant> and <parameter>data</parameter> is not exactly 16 bytes in length.</member>
  </simplelist>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>PECL mongodb 1.15.0</entry>
       <entry>
        <para>
         The <parameter>type</parameter> parameter defaults to
         <constant>MongoDB\BSON\Binary::TYPE_GENERIC</constant> if not specified.
        </para>
       </entry>
      </row>
      <row>
       <entry>PECL mongodb 1.3.0</entry>
       <entry>
        <para>
         <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname>
         is thrown if <parameter>type</parameter> is
         <constant>MongoDB\BSON\Binary::TYPE_UUID</constant> or
         <constant>MongoDB\BSON\Binary::TYPE_OLD_UUID</constant> and
         <parameter>data</parameter> is not exactly 16 bytes in length.
        </para>
       </entry>
      </row>
      <row>
       <entry>PECL mongodb 1.1.3</entry>
       <entry>
        <para>
         <classname>MongoDB\Driver\Exception\InvalidArgumentException</classname>
         is thrown if <parameter>type</parameter> is not an unsigned 8-bit
         integer.
        </para>
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>MongoDB\BSON\Binary::__construct</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php

$binary = new MongoDB\BSON\Binary('foo', MongoDB\BSON\Binary::TYPE_GENERIC);
var_dump($binary);

?>
]]>
   </programlisting>
   &example.outputs;
   <screen>
<![CDATA[
object(MongoDB\BSON\Binary)#1 (2) {
  ["data"]=>
  string(3) "foo"
  ["type"]=>
  int(0)
}
]]>
   </screen>
  </example>
 </refsect1>


 <refsect1 role="seealso">
  &reftitle.seealso;
  <simplelist>
   <member><link xlink:href="&url.mongodb.docs.bson;">BSON Types</link></member>
  </simplelist>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
