<commit_before><?php
/**
 * $Id$
 *
 * Conversion functions for different units of temperature
 *
 * http://en.wikipedia.org/wiki/Temperature_conversion_formulas
 * http://en.wikipedia.org/wiki/Conversion_of_units#Temperature
 *
 * @author <NAME>, 2009-2013 <<EMAIL>>
 */

namespace cd;

require_once('IConvert.php');

class ConvertTemperature implements IConvert
{
    protected static $units = array(
    'celcius'    => 0,
    'fahrenheit' => 0,
    'rakine'     => 0,
    'kelvin'     => 0,
    // TODO: milliKelvin
    );

    protected static $lookup = array(
    'c'        => 'celcius',
    'f'        => 'fahrenheit',
    'r'        => 'rakine',
    'k'        => 'kelvin',
    );

    protected static function getShortcode($s)
    {
        $s = trim($s);
        if (!$s)
            throw new \Exception ('no input data');

        $s = strtolower($s);

        if (isset(self::$units[$s]))
            return $s;

        if (isset(self::$lookup[$s]))
            return self::$lookup[$s];

        throw new \Exception ('unhandled unit: '.$s);
    }

    public static function convert($from, $to, $val)
    {
        $from = self::getShortcode($from);
        $to   = self::getShortcode($to);

        //convert to celcius for internal representation
        switch (strtolower($from)) {
        case 'celcius': $cel =  $val; break;
        case 'fahrenheit': $cel = ($val - 32) * (5/9); break;
        case 'rakine': $cel = ($val - 491.67) * (5/9); break;
        case 'kelvin': $cel =  $val - 273.15; break;
        default: throw new \Exception ('from val: '.$from);
        }

        switch (strtolower($to)) {
        case 'celcius': $res =  $cel; break;
        case 'fahrenheit': $res = ($cel * (9/5)) + 32; break;
        case 'rakine': $res = ($cel + 273.15) * (9/5); break;
        case 'kelvin': $res =  $cel + 273.15; break;
        default: throw new \Exception ('to val: '.$to);
        }

        return $res;
    }

}
<commit_msg>fix typo<commit_after><?php
/**
 * $Id$
 *
 * Conversion functions for different units of temperature
 *
 * http://en.wikipedia.org/wiki/Temperature_conversion_formulas
 * http://en.wikipedia.org/wiki/Conversion_of_units#Temperature
 *
 * @author <NAME>, 2009-2013 <<EMAIL>>
 */

namespace cd;

require_once('IConvert.php');

class ConvertTemperature implements IConvert
{
    protected static $units = array(
    'celcius'    => 0,
    'fahrenheit' => 0,
    'rankine'     => 0,
    'kelvin'     => 0,
    // TODO: milliKelvin
    );

    protected static $lookup = array(
    'c'        => 'celcius',
    'f'        => 'fahrenheit',
    'r'        => 'rankine',
    'k'        => 'kelvin',
    );

    protected static function getShortcode($s)
    {
        $s = trim($s);
        if (!$s)
            throw new \Exception ('no input data');

        $s = strtolower($s);

        if (isset(self::$units[$s]))
            return $s;

        if (isset(self::$lookup[$s]))
            return self::$lookup[$s];

        throw new \Exception ('unhandled unit: '.$s);
    }

    public static function convert($from, $to, $val)
    {
        $from = self::getShortcode($from);
        $to   = self::getShortcode($to);

        // convert to celcius for internal representation
        switch (strtolower($from)) {
        case 'celcius': $cel =  $val; break;
        case 'fahrenheit': $cel = ($val - 32) * (5/9); break;
        case 'rankine': $cel = ($val - 491.67) * (5/9); break;
        case 'kelvin': $cel = $val - 273.15; break;
        default: throw new \Exception ('from val: '.$from);
        }

        switch (strtolower($to)) {
        case 'celcius': $res =  $cel; break;
        case 'fahrenheit': $res = ($cel * (9/5)) + 32; break;
        case 'rankine': $res = ($cel + 273.15) * (9/5); break;
        case 'kelvin': $res = $cel + 273.15; break;
        default: throw new \Exception ('to val: '.$to);
        }

        return $res;
    }

}

{'fraction_non_alphanumeric': 0.17329255861365953, 'fraction_numerical': 0.022426095820591234, 'mean_word_length': 2.1175536139793487, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '1999938', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1302, 'n_words': 329}