<commit_before><?php

/**
 * Sort functionality for BoundingPairCollection
 *
 * PHP Version 5.4
 *
 * @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\Collection;

use ptlis\SemanticVersion\ComparatorVersion\ComparatorVersion;
use ptlis\SemanticVersion\Comparator\ComparatorInterface;
use ptlis\SemanticVersion\Comparator\GreaterThan;
use ptlis\SemanticVersion\Comparator\LessThan;

/**
 * Sort functionality for BoundingPairCollection
 */
class BoundingPairSort
{
    /**
     * Compare lower ComparatorVersions from BoundingPair.
     *
     * @param int               $factor
     * @param ComparatorVersion $lComp
     * @param ComparatorVersion $rComp
     *
     * @return int
     */
    public function compareLower($factor, ComparatorVersion $lComp = null, ComparatorVersion $rComp = null)
    {
        return $this->sharedCompare(
            new LessThan(),
            1 * $factor,
            -1 * $factor,
            '>=',
            $lComp,
            $rComp
        );
    }


    /**
     * Compare upper ComparatorVersions from BoundingPair.
     *
     * @param int               $factor
     * @param ComparatorVersion $lComp
     * @param ComparatorVersion $rComp
     *
     * @return int
     */
    public function compareUpper($factor, ComparatorVersion $lComp = null, ComparatorVersion $rComp = null)
    {
        return $this->sharedCompare(
            new GreaterThan(),
            -1 * $factor,
            1 * $factor,
            '<=',
            $lComp,
            $rComp
        );
    }


    /**
     * Shared comparison logic for upper & lower ComparatorVersions
     *
     * @param ComparatorInterface       $comparator
     * @param int                       $rightLess
     * @param int                       $rightGreater
     * @param string                    $symbol
     * @param ComparatorVersion|null    $lComp
     * @param ComparatorVersion|null    $rComp
     *
     * @return int
     */
    private function sharedCompare(
        ComparatorInterface $comparator,<commit_msg>Docblock fixes.<commit_after><?php

/**
 * Sort functionality for BoundingPairCollection
 *
 * PHP Version 5.4
 *
 * @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\Collection;

use ptlis\SemanticVersion\ComparatorVersion\ComparatorVersion;
use ptlis\SemanticVersion\Comparator\ComparatorInterface;
use ptlis\SemanticVersion\Comparator\GreaterThan;
use ptlis\SemanticVersion\Comparator\LessThan;

/**
 * Sort functionality for BoundingPairCollection
 */
class BoundingPairSort
{
    /**
     * Compare lower ComparatorVersions from BoundingPair.
     *
     * @param int                       $factor
     * @param ComparatorVersion|null    $lComp
     * @param ComparatorVersion|null    $rComp
     *
     * @return int
     */
    public function compareLower($factor, ComparatorVersion $lComp = null, ComparatorVersion $rComp = null)
    {
        return $this->sharedCompare(
            new LessThan(),
            1 * $factor,
            -1 * $factor,
            '>=',
            $lComp,
            $rComp
        );
    }


    /**
     * Compare upper ComparatorVersions from BoundingPair.
     *
     * @param int                       $factor
     * @param ComparatorVersion|null    $lComp
     * @param ComparatorVersion|null    $rComp
     *
     * @return int
     */
    public function compareUpper($factor, ComparatorVersion $lComp = null, ComparatorVersion $rComp = null)
    {
        return $this->sharedCompare(
            new GreaterThan(),
            -1 * $factor,
            1 * $factor,
            '<=',
            $lComp,
            $rComp
        );
    }


    /**
     * Shared comparison logic for upper & lower ComparatorVersions
     *
     * @param ComparatorInterface       $comparator
     * @param int                       $rightLess
     * @param int                       $rightGreater
     * @param string                    $symbol
     * @param ComparatorVersion|null    $lComp
     * @param ComparatorVersion|null    $rComp
     *
     * @return int
     */
    private function sharedCompare(
        ComparatorInterface $comparator,
{'fraction_non_alphanumeric': 0.09338267305180671, 'fraction_numerical': 0.0043535045711798, 'mean_word_length': 2.009168303863785, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '6740889', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1246, 'n_words': 310}