<commit_before><?php

/*
 * This file is part of Swap.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Swap\Model;

/**
 * Represents a currency pair.
 *
 * @author <NAME> <<EMAIL>>
 */
final class CurrencyPair
{
    private $baseCurrency;
    private $quoteCurrency;

    /**
     * Creates a new currency pair.
     *
     * @param string $baseCurrency  The base currency ISO 4217 code
     * @param string $quoteCurrency The quote currency ISO 4217 code
     */
    public function __construct($baseCurrency, $quoteCurrency)
    {
        $this->baseCurrency = $baseCurrency;
        $this->quoteCurrency = $quoteCurrency;
    }

    /**
     * Creates a currency pair from a string.
     *
     * @param string $string A string in the form EUR/USD
     *
     * @throws \InvalidArgumentException
     *
     * @return CurrencyPair
     */
    public static function createFromString($string)
    {
        $parts = explode('/', $string);

        if (!isset($parts[0]) || 3 !== strlen($parts[0]) || !isset($parts[1]) || 3 !== strlen($parts[1])) {
            throw new \InvalidArgumentException('The currency pair must be in the form "EUR/USD".');
        }

        return new self($parts[0], $parts[1]);
    }

    /**
     * Gets the base currency.
     *
     * @return string
     */
    public function getBaseCurrency()
    {
        return $this->baseCurrency;
    }

    /**
     * Gets the quote currency.
     *
     * @return string
     */
    public function getQuoteCurrency()
    {
        return $this->quoteCurrency;
    }

    /**
     * Check if the pair is identical.
     *
     * @return bool
     */
    public function isIdentical()
    {
        return $this->baseCurrency === $this->quoteCurrency;
    }

    /**
     * Returns a string representation of the pair.
     *
     * @return string
     */
    public function toString()
    {
        return sprintf('%s/%s', $this->baseCurrency, $this->quoteCurrency);
    }

    /**
     * Returns the hashed representation of the pair.
     *
     * @return string
     */
    public function toHash()
    {
        return md5($this->toString());
    }

    /**
     * Returns a string representation of the pair.
     *
     * @return string<commit_msg>Use sha1 instead of md5<commit_after><?php

/*
 * This file is part of Swap.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Swap\Model;

/**
 * Represents a currency pair.
 *
 * @author <NAME> <<EMAIL>>
 */
final class CurrencyPair
{
    private $baseCurrency;
    private $quoteCurrency;

    /**
     * Creates a new currency pair.
     *
     * @param string $baseCurrency  The base currency ISO 4217 code
     * @param string $quoteCurrency The quote currency ISO 4217 code
     */
    public function __construct($baseCurrency, $quoteCurrency)
    {
        $this->baseCurrency = $baseCurrency;
        $this->quoteCurrency = $quoteCurrency;
    }

    /**
     * Creates a currency pair from a string.
     *
     * @param string $string A string in the form EUR/USD
     *
     * @throws \InvalidArgumentException
     *
     * @return CurrencyPair
     */
    public static function createFromString($string)
    {
        $parts = explode('/', $string);

        if (!isset($parts[0]) || 3 !== strlen($parts[0]) || !isset($parts[1]) || 3 !== strlen($parts[1])) {
            throw new \InvalidArgumentException('The currency pair must be in the form "EUR/USD".');
        }

        return new self($parts[0], $parts[1]);
    }

    /**
     * Gets the base currency.
     *
     * @return string
     */
    public function getBaseCurrency()
    {
        return $this->baseCurrency;
    }

    /**
     * Gets the quote currency.
     *
     * @return string
     */
    public function getQuoteCurrency()
    {
        return $this->quoteCurrency;
    }

    /**
     * Check if the pair is identical.
     *
     * @return bool
     */
    public function isIdentical()
    {
        return $this->baseCurrency === $this->quoteCurrency;
    }

    /**
     * Returns a string representation of the pair.
     *
     * @return string
     */
    public function toString()
    {
        return sprintf('%s/%s', $this->baseCurrency, $this->quoteCurrency);
    }

    /**
     * Returns the hashed representation of the pair.
     *
     * @return string
     */
    public function toHash()
    {
        return sha1($this->toString());
    }

    /**
     * Returns a string representation of the pair.
     *
     * @return string
{'fraction_non_alphanumeric': 0.12444444444444444, 'fraction_numerical': 0.007619047619047619, 'mean_word_length': 2.1071663379355687, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, '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': '2236770', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1366, 'n_words': 403}