<commit_before><?php

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

declare(strict_types=1);

namespace Sylius\Component\Currency\Model;

use Sylius\Component\Resource\Model\TimestampableTrait;

class ExchangeRate implements ExchangeRateInterface
{
    use TimestampableTrait;

    /** @var mixed */
    protected $id;

    /** @var float|null */
    protected $ratio;

    /** @var CurrencyInterface|null */
    protected $sourceCurrency;

    /** @var CurrencyInterface|null */
    protected $targetCurrency;

    public function __construct()
    {
        $this->createdAt = new \DateTime();
    }

    /**
     * {@inheritdoc}
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * {@inheritdoc}
     */
    public function getRatio(): ?float
    {
        // It looks like Doctrine is hydrating decimal field as string, force casting to float.
        /** @psalm-suppress DocblockTypeContradiction */
        return is_string($this->ratio) ? (float) $this->ratio : $this->ratio;
    }

    /**
     * {@inheritdoc}
     *
     * @throws \InvalidArgumentException
     */
    public function setRatio(?float $ratio): void
    {
        $this->ratio = $ratio;<commit_msg>Fix all Psalm errors<commit_after><?php

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

declare(strict_types=1);

namespace Sylius\Component\Currency\Model;

use Sylius\Component\Resource\Model\TimestampableTrait;

class ExchangeRate implements ExchangeRateInterface
{
    use TimestampableTrait;

    /** @var mixed */
    protected $id;

    /** @var float|null */
    protected $ratio;

    /** @var CurrencyInterface|null */
    protected $sourceCurrency;

    /** @var CurrencyInterface|null */
    protected $targetCurrency;

    public function __construct()
    {
        $this->createdAt = new \DateTime();
    }

    /**
     * {@inheritdoc}
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * {@inheritdoc}
     */
    public function getRatio(): ?float
    {
        /**
         * It looks like Doctrine is hydrating decimal field as string, force casting to float.
         *
         * @psalm-suppress DocblockTypeContradiction
         * @psalm-suppress RedundantConditionGivenDocblockType
         */
        return is_string($this->ratio) ? (float) $this->ratio : $this->ratio;
    }

    /**
     * {@inheritdoc}
     *
     * @throws \InvalidArgumentException
     */
    public function setRatio(?float $ratio): void
    {
        $this->ratio = $ratio;
{'fraction_non_alphanumeric': 0.12026883622214361, 'fraction_numerical': 0.0007074637424831977, 'mean_word_length': 2.4699386503067484, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6306209', 'n_tokens_mistral': 835, 'n_tokens_neox': 810, 'n_words': 214}