<commit_before><?php

/**
 * ComparatorVersion less than comparator.
 *
 * PHP Version 5.3
 *
 * @copyright   (c) 2014 <NAME>
 * @author      <NAME> <<EMAIL>>
 * @license     http://opensource.org/licenses/MIT MIT
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ptlis\SemanticVersion\ComparatorVersion\Comparator;

use ptlis\SemanticVersion\ComparatorVersion\ComparatorVersion;
use ptlis\SemanticVersion\Version\Comparator\ComparatorInterface as VersionComparatorInterface;
use ptlis\SemanticVersion\Version\Comparator\EqualTo as VersionEqualTo;
use ptlis\SemanticVersion\Version\Comparator\LessThan as VersionLessThan;

/**
 * ComparatorVersion less than comparator.
 */
class LessThan extends AbstractComparator
{
    /**
     * Retrieve the comparator's symbol.
     *
     * @return string
     */
    public static function getSymbol()
    {
        return '<';
    }


    /**
     * Return true if the left ComparatorVersion is less than right version.
     *
     * @param ComparatorVersion $lCompVersion
     * @param ComparatorVersion $rCompVersion
     *
     * @return boolean
     */
    public function compare(ComparatorVersion $lCompVersion, ComparatorVersion $rCompVersion)
    {
        $versionLessThan = new VersionLessThan();
        $versionEqualTo = new VersionEqualTo();

        $lessThan = false;

        // Left version number less than right
        if ($versionLessThan->compare($lCompVersion->getVersion(), $rCompVersion->getVersion())) {
            $lessThan = true;

        // Otherwise compare comparator
        } elseif ($versionEqualTo->compare($lCompVersion->getVersion(), $rCompVersion->getVersion())
                && 1 === $this->compareComparators($lCompVersion->getComparator(), $rCompVersion->getComparator())) {
            $lessThan = true;
        }

        return $lessThan;
    }


    /**
     * Returns 1 if left comparator is (effectively) lower, 0 if equal and -1 if greater.
     *
     * Matrix used:
     *
     *          right
     *     +----+----+----+----+----+----+
     *     |    | <  | <= | =  | >= | >  |
     *     +----+----+----+----+----+----+
     *  l  | <  | 0  | 1  | 1  | 1  | 1  |
     *  e  | <= | -1 | 0  | 1  | 1  | 1  |
     *  f  | =  | -1 | -1 | 0  | 1  | 1  |
     *  t  | >= | -1 | -1 | -1 | 0  | 1  |
     *     | >  | -1 | -1 | -1 | -1 | 0  |
     *     +----+----+----+----+----+----+
     *
     * @param VersionComparatorInterface $lComp
     * @param VersionComparatorInterface $rComp
     *
     * @return bool
     */
    private function compareComparators(VersionComparatorInterface $lComp, VersionComparatorInterface $rComp)
    {
        // Lookup table for comparator comparisons, first index is left comparator & next is right.
        $lookupTable = array(
            '<'     => array(
                '<'     => 0,
                '<='    => 1,
                '='     => 1,
                '>='    => 1,<commit_msg>Docblock fix.<commit_after><?php

/**
 * ComparatorVersion less than comparator.
 *
 * PHP Version 5.3
 *
 * @copyright   (c) 2014 <NAME>
 * @author      <NAME> <<EMAIL>>
 * @license     http://opensource.org/licenses/MIT MIT
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ptlis\SemanticVersion\ComparatorVersion\Comparator;

use ptlis\SemanticVersion\ComparatorVersion\ComparatorVersion;
use ptlis\SemanticVersion\Version\Comparator\ComparatorInterface as VersionComparatorInterface;
use ptlis\SemanticVersion\Version\Comparator\EqualTo as VersionEqualTo;
use ptlis\SemanticVersion\Version\Comparator\LessThan as VersionLessThan;

/**
 * ComparatorVersion less than comparator.
 */
class LessThan extends AbstractComparator
{
    /**
     * Retrieve the comparator's symbol.
     *
     * @return string
     */
    public static function getSymbol()
    {
        return '<';
    }


    /**
     * Return true if the left ComparatorVersion is less than right version.
     *
     * @param ComparatorVersion $lCompVersion
     * @param ComparatorVersion $rCompVersion
     *
     * @return boolean
     */
    public function compare(ComparatorVersion $lCompVersion, ComparatorVersion $rCompVersion)
    {
        $versionLessThan = new VersionLessThan();
        $versionEqualTo = new VersionEqualTo();

        $lessThan = false;

        // Left version number less than right
        if ($versionLessThan->compare($lCompVersion->getVersion(), $rCompVersion->getVersion())) {
            $lessThan = true;

        // Otherwise compare comparator
        } elseif ($versionEqualTo->compare($lCompVersion->getVersion(), $rCompVersion->getVersion())
                && 1 === $this->compareComparators($lCompVersion->getComparator(), $rCompVersion->getComparator())) {
            $lessThan = true;
        }

        return $lessThan;
    }


    /**
     * Returns 1 if left comparator is (effectively) lower, 0 if equal and -1 if greater.
     *
     * Matrix used:
     *
     *          right
     *     +----+----+----+----+----+----+
     *     |    | <  | <= | =  | >= | >  |
     *     +----+----+----+----+----+----+
     *  l  | <  | 0  | 1  | 1  | 1  | 1  |
     *  e  | <= | -1 | 0  | 1  | 1  | 1  |
     *  f  | =  | -1 | -1 | 0  | 1  | 1  |
     *  t  | >= | -1 | -1 | -1 | 0  | 1  |
     *     | >  | -1 | -1 | -1 | -1 | 0  |
     *     +----+----+----+----+----+----+
     *
     * @param VersionComparatorInterface $lComp
     * @param VersionComparatorInterface $rComp
     *
     * @return integer
     */
    private function compareComparators(VersionComparatorInterface $lComp, VersionComparatorInterface $rComp)
    {
        // Lookup table for comparator comparisons, first index is left comparator & next is right.
        $lookupTable = array(
            '<'     => array(
                '<'     => 0,
                '<='    => 1,
                '='     => 1,
                '>='    => 1,
{'fraction_non_alphanumeric': 0.14687862228845835, 'fraction_numerical': 0.012916045702930949, 'mean_word_length': 1.982716049382716, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 49, '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': '418676', 'n_tokens_mistral': 1831, 'n_tokens_neox': 1784, 'n_words': 420}