<commit_before><?php

namespace Pamil\Rounder;

/**
 * @author <NAME> <<EMAIL>>
 */
class BasicRounder extends AbstractRounder implements Rounder
{
    /**
     * {@inheritdoc}
     */
    public function roundHalfUp($number, $precision = 0)
    {
        $multiplier = static::computeMultiplier($precision);

        $multipliedNumber = $number * $multiplier;
        $multipliedNumberRoundedDown = static::roundDown($multipliedNumber);

        $numberRoundedHalfUp = $multipliedNumberRoundedDown / $multiplier;
        if (($multipliedNumber - $multipliedNumberRoundedDown) >= 0.5) {
            $numberRoundedHalfUp += (1 / $multiplier);
        }

        return $numberRoundedHalfUp;
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfDown($number, $precision = 0)
    {
        $multiplier = static::computeMultiplier($precision);

        $multipliedNumber = $number * $multiplier;
        $multipliedNumberRoundedDown = static::roundDown($multipliedNumber);

        $numberRoundedHalfDown = $multipliedNumberRoundedDown / $multiplier;
        if (($multipliedNumber - $multipliedNumberRoundedDown) > 0.5) {
            $numberRoundedHalfDown += (1 / $multiplier);
        }

        return $numberRoundedHalfDown;
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfEven($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_EVEN);
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfOdd($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_ODD);
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfAwayFromZero($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_UP);
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfTowardsZero($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_DOWN);
    }

    /**
     * {@inheritdoc}
     */
    public function roundUp($number, $precision = 0)
    {
        $multiplier = static::computeMultiplier($precision);

        return ceil($number * $multiplier) / $multiplier;
    }

    /**
     * {@inheritdoc}
     */
    public function roundDown($number, $precision = 0)
    {
        $multiplier = static::computeMultiplier($precision);

        return floor($number * $multiplier) / $multiplier;
    }

    /**
     * {@inheritdoc}
     */
    public function roundAwayFromZero($number, $precision = 0)
    {
        return $number > 0
            ? static::roundUp($number, $precision)
            : static::roundDown($number, $precision)
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function roundTowardsZero($number, $precision = 0)
    {
        return $number > 0
            ? static::roundDown($number, $precision)
            : static::roundUp($number, $precision)
        ;
    }

    protected static function computeMultiplier($precision)
    {
        return pow(10, $precision);
    }
}<commit_msg>Refactored to 2.0 API<commit_after><?php

namespace Pamil\Rounder;

/**
 * @author <NAME> <<EMAIL>>
 */
class BasicRounder extends AbstractRounder implements Rounder
{
    /**
     * {@inheritdoc}
     */
    public function roundHalfUp($number, $precision = 0)
    {
        $multiplier = $this->computeMultiplier($precision);

        $multipliedNumber = $number * $multiplier;
        $multipliedNumberRoundedDown = $this->roundDown($multipliedNumber);

        $numberRoundedHalfUp = $multipliedNumberRoundedDown / $multiplier;
        if (($multipliedNumber - $multipliedNumberRoundedDown) >= 0.5) {
            $numberRoundedHalfUp += (1 / $multiplier);
        }

        return $numberRoundedHalfUp;
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfDown($number, $precision = 0)
    {
        $multiplier = $this->computeMultiplier($precision);

        $multipliedNumber = $number * $multiplier;
        $multipliedNumberRoundedDown = $this->roundDown($multipliedNumber);

        $numberRoundedHalfDown = $multipliedNumberRoundedDown / $multiplier;
        if (($multipliedNumber - $multipliedNumberRoundedDown) > 0.5) {
            $numberRoundedHalfDown += (1 / $multiplier);
        }

        return $numberRoundedHalfDown;
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfEven($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_EVEN);
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfOdd($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_ODD);
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfAwayFromZero($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_UP);
    }

    /**
     * {@inheritdoc}
     */
    public function roundHalfTowardsZero($number, $precision = 0)
    {
        return round($number, $precision, PHP_ROUND_HALF_DOWN);
    }

    /**
     * {@inheritdoc}
     */
    public function roundUp($number, $precision = 0)
    {
        $multiplier = $this->computeMultiplier($precision);

        return ceil($number * $multiplier) / $multiplier;
    }

    /**
     * {@inheritdoc}
     */
    public function roundDown($number, $precision = 0)
    {
        $multiplier = $this->computeMultiplier($precision);

        return floor($number * $multiplier) / $multiplier;
    }

    /**
     * {@inheritdoc}
     */
    public function roundAwayFromZero($number, $precision = 0)
    {
        return $number > 0
            ? $this->roundUp($number, $precision)
            : $this->roundDown($number, $precision)
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function roundTowardsZero($number, $precision = 0)
    {
        return $number > 0
            ? $this->roundDown($number, $precision)
            : $this->roundUp($number, $precision)
        ;
    }

    protected function computeMultiplier($precision)
    {
        return pow(10, $precision);
    }
}
{'fraction_non_alphanumeric': 0.1335644708601618, 'fraction_numerical': 0.006934125804853888, 'mean_word_length': 2.4225988700564973, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '1864906', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1839, 'n_words': 320}