<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.measure.edit">
    <title>Manipulating Measurements</title>

    <para>
        Parsing and normalization of input, combined with output to localized notations makes data
        accessible to users in different locales. Many additional methods exist in
        <classname>Zend_Measure_*</classname> components to manipulate and work with this data,
        after it has been normalized.
    </para>

    <itemizedlist>
        <listitem>
            <para>
                <link linkend="zend.measure.edit.convert"><code>Convert</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link linkend="zend.measure.edit.add"><code>Add and subtract</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link linkend="zend.measure.edit.equal"><code>Compare to boolean</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link
                    linkend="zend.measure.edit.compare"><code>Compare to
                    greater/smaller</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link
                    linkend="zend.measure.edit.changevalue"><code>Manually change
                    values</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link
                    linkend="zend.measure.edit.changetype"><code>Manually change types</code></link>
            </para>
        </listitem>
    </itemizedlist>

    <sect2 id="zend.measure.edit.convert">
        <title>Convert</title>

        <para>
            Probably the most important feature is the conversion into different units of
            measurement. The conversion of a unit can be done any number of times using the method
            <methodname>convertTo()</methodname>. Units of measurement can only be converted to
            other units of the same type (class). Therefore, it is not possible to convert (e.g.) a
            length into a weight, which would might encourage poor programming practices and allow
            errors to propagate without exceptions.
        </para>

        <para>
            The <code>convertTo</code> method accepts an optional parameter. With this parameter you
            can define an precision for the returned output. The standard precision is
            '<code>2</code>'.
        </para>

        <example id="zend.measure.edit.convert.example-1">
            <title>Convert</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale('de');
$mystring = "1.234.567,89";
$unit = new Zend_Measure_Weight($mystring,'POND', $locale);

print "Kilo:".$unit->convertTo('KILOGRAM');

// constants are considered "better practice" than strings
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON);

// define a precision for the output
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON, 3);
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.measure.edit.add">
        <title>Add and subtract</title>

        <para>
            Measurements can be added together using <methodname>add()</methodname> and subtracted
            using <methodname>sub()</methodname>. Each addition will create a new object for the
            result. The actual object will never be changed by the class. The new object will be of
            the same type as the originating object. Dynamic objects support a fluid style of
            programming, where complex sequences of operations can be nested without risk of
            side-effects altering the input objects.
        </para>

        <para>
            <example id="zend.measure.edit.add.example-1">
                <title>Adding units</title>

                <programlisting language="php"><![CDATA[
// Define objects
$unit = new Zend_Measure_Length(200, Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure_Length(1, Zend_Measure_Length::METER);

// Add $unit2 to $unit
$sum = $unit->add($unit2);

echo $sum; // outputs "300 cm"
]]></programlisting>
            </example>
        </para>

        <note>
            <title>Automatic conversion</title><commit_msg>[ZF-9831] Zend_Measure:<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.measure.edit">
    <title>Manipulating Measurements</title>

    <para>
        Parsing and normalization of input, combined with output to localized notations makes data
        accessible to users in different locales. Many additional methods exist in
        <classname>Zend_Measure_*</classname> components to manipulate and work with this data,
        after it has been normalized.
    </para>

    <itemizedlist>
        <listitem>
            <para>
                <link linkend="zend.measure.edit.convert"><code>Convert</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link linkend="zend.measure.edit.add"><code>Add and subtract</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link linkend="zend.measure.edit.equal"><code>Compare to boolean</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link
                    linkend="zend.measure.edit.compare"><code>Compare to
                    greater/smaller</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link
                    linkend="zend.measure.edit.changevalue"><code>Manually change
                    values</code></link>
            </para>
        </listitem>

        <listitem>
            <para>
                <link
                    linkend="zend.measure.edit.changetype"><code>Manually change types</code></link>
            </para>
        </listitem>
    </itemizedlist>

    <sect2 id="zend.measure.edit.convert">
        <title>Convert</title>

        <para>
            Probably the most important feature is the conversion into different units of
            measurement. The conversion of a unit can be done any number of times using the method
            <methodname>convertTo()</methodname>. Units of measurement can only be converted to
            other units of the same type (class). Therefore, it is not possible to convert (e.g.) a
            length into a weight, which would might encourage poor programming practices and allow
            errors to propagate without exceptions.
        </para>

        <para>
            The <code>convertTo</code> method accepts an optional parameter. With this parameter you
            can define an precision for the returned output. The standard precision is
            '<code>2</code>'.
        </para>

        <example id="zend.measure.edit.convert.example-1">
            <title>Convert</title>

            <programlisting language="php"><![CDATA[
$locale = new Zend_Locale('de');
$mystring = "1.234.567,89";
$unit = new Zend_Measure_Weight($mystring,'POND', $locale);

print "Kilo:".$unit->convertTo('KILOGRAM');

// constants are considered "better practice" than strings
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON);

// define a precision for the output
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON, 3);
]]></programlisting>
        </example>
    </sect2>

    <sect2 id="zend.measure.edit.add">
        <title>Add and subtract</title>

        <para>
            Measurements can be added together using <methodname>add()</methodname> and subtracted
            using <methodname>sub()</methodname>. The result will use the same type as the
            originating object. Dynamic objects support a fluid style of programming, where complex
            sequences of operations can be nested without risk of side-effects altering the input
            objects.
        </para>

        <para>
            <example id="zend.measure.edit.add.example-1">
                <title>Adding units</title>

                <programlisting language="php"><![CDATA[
// Define objects
$unit = new Zend_Measure_Length(200, Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure_Length(1, Zend_Measure_Length::METER);

// Add $unit2 to $unit
$sum = $unit->add($unit2);

echo $sum; // outputs "300 cm"
]]></programlisting>
            </example>
        </para>

        <note>
            <title>Automatic conversion</title>
{'fraction_non_alphanumeric': 0.11522824950633058, 'fraction_numerical': 0.007434080613311651, 'mean_word_length': 2.155001832172957, 'pattern_counts': {'":': 0, '<': 205, '<?xml version=': 2, '>': 213, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7247105', 'n_tokens_mistral': 2405, 'n_tokens_neox': 2247, 'n_words': 668}