<commit_before><sect1 id="zend.measure.edit">
    <title>Manipulating measurements</title>
    <para>
        Naturally, in- and output of measurements is not enough - it is equally important to be able to manipulate them.
        This can be done using the following methods.
    </para>
    <para>
        <link linkend="zend.measure.edit.convert"><code>Convert</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.add"><code>Add and subtract</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.equal"><code>Compare</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.compare"><code>Calculate differences</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.changevalue"><code>Manually change values</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.changetype"><code>Manually change types</code></link>
    </para>
    <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 <code>convertTo()</code>.
        </para>
        <note>
            <para>
                Units of measurement can only be converted to other units of the same type.
            </para>
        </note>
        <para>
            Therefore, it is not possible to convert (e.g.) a length into a weight.
        </para>
        <example>
            <title>Convert</title>
            <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Weight');
Zend::loadClass('Zend_Locale');

$locale = new Zend_Locale('de');

$mystring = "1.234.567,89";
$unit = new Zend_Measure($mystring,Zend_Measure_Weight::POUND,$locale);

print "Kilo:".$unit->convertTo(Zend_Measure_Weight::KILOGRAM);
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON);
?>]]></programlisting>
        </example>
    </sect2>
    <sect2 id="zend.measure.edit.add">
        <title>Add and subtract</title>
        <para>
            Measurements can be added together using <code>add()</code> and subtracted using <code>sub()</code>.
        </para>
        <para>
            <example>
                <title>Adding units</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define objects
$unit = new Zend_Measure(200,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

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

echo $sum;
?>]]></programlisting>
            </example>
        </para>
        <note>
            Each addition will create a new object for the result.
        </note>
        <note>
            The new object will be of the same type as the originating object.
        </note>
        <note>
            Adding one object to another will automatically convert it to the
            correct unit. It is not neccessary to call <link linkend="zend.measure.edit.convert"><code>convertTo()</code></link>
            before adding different units.
        </note>
        <para>
            <example>
                <title>Subtract</title>
                <para>
                    Subtraction of measurements works just like addition.
                </para>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define objects
$unit = new Zend_Measure(200,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

// Subtract $unit2 from $unit
$sum = $unit->sub($unit2);

echo $sum;
?>]]></programlisting>
            </example>
        </para>
    </sect2>
    <sect2 id="zend.measure.edit.equal">
        <title>Compare</title>
        <para>
            Of course, measurements can also be compared.
        </para>
        <para>
            <example>
                <title>Different measurements</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define measurements
$unit = new Zend_Measure(100,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

if ($unit->equals($unit2)) {
    print "Both measurements are identical";
} else {
    print "These are different measurements";
}
?>]]></programlisting>
            </example>
            <example>
                <title>Identical measurements</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define measurements
$unit = new Zend_Measure(100,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

$unit2->setType(Zend_Measure_Length::CENTIMETER);

if ($unit->equals($unit2)) {
    print "Both measurements are identical";
} else {
    print "These are different measurements";
}
?>]]></programlisting>
            </example>
        </para>
        <note>
            <code>equals()</code> will return <code>TRUE</code> only if both the value
            and the unit of measure are identical.
        </note>
    </sect2>
    <sect2 id="zend.measure.edit.compare">
        <title>Calculate differences</title>
        <para>
            To determine if a measurement is less or greater than another, you can use the
            <code>compare()</code> method. It will return the difference between two objects
            as an integer value.
        </para>
        <para>
            Identical measurements will return 0. Lesser ones will return a negative, greater ones 
            a positive value.
        </para>
        <para>
            <example>
                <title>Difference</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

$unit = new Zend_Measure(100,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);
$unit3 = new Zend_Measure(1.2,Zend_Measure_Length::METER);

print "Equal:".$unit2->compare($unit);
print "Greater:".$unit2->compare($unit3);
print "Lesser:".$unit3->compare($unit2);
?>]]></programlisting><commit_msg>Zend_Measure Documentation:  - fixed docu dtd valid problems<commit_after><sect1 id="zend.measure.edit">
    <title>Manipulating measurements</title>
    <para>
        Naturally, in- and output of measurements is not enough - it is equally important to be able to manipulate them.
        This can be done using the following methods.
    </para>
    <para>
        <link linkend="zend.measure.edit.convert"><code>Convert</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.add"><code>Add and subtract</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.equal"><code>Compare</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.compare"><code>Calculate differences</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.changevalue"><code>Manually change values</code></link>
    </para>
    <para>
        <link linkend="zend.measure.edit.changetype"><code>Manually change types</code></link>
    </para>
    <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 <code>convertTo()</code>.
        </para>
        <note>
            <title>Conversion limit</title>
            <para>
                Units of measurement can only be converted to other units of the same type.
            </para>
        </note>
        <para>
            Therefore, it is not possible to convert (e.g.) a length into a weight.
        </para>
        <example>
            <title>Convert</title>
            <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Weight');
Zend::loadClass('Zend_Locale');

$locale = new Zend_Locale('de');

$mystring = "1.234.567,89";
$unit = new Zend_Measure($mystring,Zend_Measure_Weight::POUND,$locale);

print "Kilo:".$unit->convertTo(Zend_Measure_Weight::KILOGRAM);
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON);
?>]]></programlisting>
        </example>
    </sect2>
    <sect2 id="zend.measure.edit.add">
        <title>Add and subtract</title>
        <para>
            Measurements can be added together using <code>add()</code> and subtracted using <code>sub()</code>.
        </para>
        <para>
            <example>
                <title>Adding units</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define objects
$unit = new Zend_Measure(200,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

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

echo $sum;
?>]]></programlisting>
            </example>
        </para>
        <note>
            <title>Addition returns object</title>
            <para>
                Each addition will create a new object for the result.
                The actual object will never be changed by the class.
            </para>
            <para>
                The new object will be of the same type as the originating object.
            </para>
        </note>
        <note>
            <title>Automatic conversion</title>
            <para>
                Adding one object to another will automatically convert it to the
                correct unit. It is not neccessary to call <link linkend="zend.measure.edit.convert"><code>convertTo()</code></link>
                before adding different units.
            </para>
        </note>
        <para>
            <example>
                <title>Subtract</title>
                <para>
                    Subtraction of measurements works just like addition.
                </para>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define objects
$unit = new Zend_Measure(200,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

// Subtract $unit2 from $unit
$sum = $unit->sub($unit2);

echo $sum;
?>]]></programlisting>
            </example>
        </para>
    </sect2>
    <sect2 id="zend.measure.edit.equal">
        <title>Compare</title>
        <para>
            Of course, measurements can also be compared.
        </para>
        <para>
            <example>
                <title>Different measurements</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define measurements
$unit = new Zend_Measure(100,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

if ($unit->equals($unit2)) {
    print "Both measurements are identical";
} else {
    print "These are different measurements";
}
?>]]></programlisting>
            </example>
            <example>
                <title>Identical measurements</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

// Define measurements
$unit = new Zend_Measure(100,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);

$unit2->setType(Zend_Measure_Length::CENTIMETER);

if ($unit->equals($unit2)) {
    print "Both measurements are identical";
} else {
    print "These are different measurements";
}
?>]]></programlisting>
            </example>
        </para>
        <note>
            <title>Equality</title>
            <para>
                <code>equals()</code> will return <code>TRUE</code> only if both the value
                and the unit of measure are identical.
            </para>
        </note>
    </sect2>
    <sect2 id="zend.measure.edit.compare">
        <title>Calculate differences</title>
        <para>
            To determine if a measurement is less or greater than another, you can use the
            <code>compare()</code> method. It will return the difference between two objects
            as an integer value.
        </para>
        <para>
            Identical measurements will return 0. Lesser ones will return a negative, greater ones 
            a positive value.
        </para>
        <para>
            <example>
                <title>Difference</title>
                <programlisting role="php"><![CDATA[<?php
require_once 'Zend.php';
Zend::loadClass('Zend_Measure');
Zend::loadClass('Zend_Measure_Length');

$unit = new Zend_Measure(100,Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure(1,Zend_Measure_Length::METER);
$unit3 = new Zend_Measure(1.2,Zend_Measure_Length::METER);

print "Equal:".$unit2->compare($unit);
print "Greater:".$unit2->compare($unit3);
print "Lesser:".$unit3->compare($unit2);
?>]]></programlisting>
{'fraction_non_alphanumeric': 0.13807871224987078, 'fraction_numerical': 0.008565310492505354, 'mean_word_length': 2.716794731064764, 'pattern_counts': {'":': 0, '<': 321, '<?xml version=': 0, '>': 341, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7321677', 'n_tokens_mistral': 4142, 'n_tokens_neox': 3972, 'n_words': 969}