<commit_before><?php

namespace SCL\Currency;

use SCL\Currency\TaxedPrice\Factory;
use SCL\Currency\TaxedPrice\DefaultFactory;

class TaxedPriceFactory
{
    /**
     * @var Factory
     */
    private $priceFactory;

    /**
     * @var Factory
     */
    private static $staticFactory;

    public function __construct(Factory $priceFactory)
    {
        $this->priceFactory = $priceFactory;
    }

    /**
     * @param Money|float $amount
     * @param Money|float $tax
     * @param string      $currency
     *
     * @return TaxedPrice
     */
    public function createTaxedPrice($amount, $tax, $currency = null)
    {
        if ($amount instanceof Money) {
            return $this->priceFactory->createWithObjects($amount, $tax);
        }

        if (null === $currency) {
            return $this->priceFactory->createWithValuesAndDefaultCurrency($amount, $tax);
        }

        return $this->priceFactory->createWithValues($amount, $tax, $currency);
    }

    /**
     * @return Factory
     */
    public static function createDefaultInstance()
    {
        return new self(new DefaultFactory(
            MoneyFactory::getStaticFactory()->getInternalFactory()
        ));
    }

    public static function setStaticFactory(TaxedPriceFactory $factory)
    {
        self::$staticFactory = $factory;
    }

    /**
     * Only really intended for testing.
     */
    public static function clearStaticFactory()
    {
        self::$staticFactory = null;
    }

    /**
     * @return Factory
     */
    public static function getStaticFactory()
    {
        self::assertStaticFactoryHasBeenCreated();

        return self::$staticFactory;
    }

    /**
     * staticCreateTaxedPrice
     *
     * @param Money|float $amount
     * @param Money|float $tax
     * @param string      $currency
     *
     * @return TaxedPrice
     */
    public function staticCreate($amount, $tax, $currency = null)
    {
        self::assertStaticFactoryHasBeenCreated();

        return self::$staticFactory->createTaxedPrice($amount, $tax, $currency);
    }

    private static function assertStaticFactoryHasBeenCreated()
    {
        if (!self::$staticFactory) {
            self::$staticFactory = self::createDefaultInstance();
        }
    }
}<commit_msg>staticCreate() is static<commit_after><?php

namespace SCL\Currency;

use SCL\Currency\TaxedPrice\Factory;
use SCL\Currency\TaxedPrice\DefaultFactory;

class TaxedPriceFactory
{
    /**
     * @var Factory
     */
    private $priceFactory;

    /**
     * @var Factory
     */
    private static $staticFactory;

    public function __construct(Factory $priceFactory)
    {
        $this->priceFactory = $priceFactory;
    }

    /**
     * @param Money|float $amount
     * @param Money|float $tax
     * @param string      $currency
     *
     * @return TaxedPrice
     */
    public function createTaxedPrice($amount, $tax, $currency = null)
    {
        if ($amount instanceof Money) {
            return $this->priceFactory->createWithObjects($amount, $tax);
        }

        if (null === $currency) {
            return $this->priceFactory->createWithValuesAndDefaultCurrency($amount, $tax);
        }

        return $this->priceFactory->createWithValues($amount, $tax, $currency);
    }

    /**
     * @return Factory
     */
    public static function createDefaultInstance()
    {
        return new self(new DefaultFactory(
            MoneyFactory::getStaticFactory()->getInternalFactory()
        ));
    }

    public static function setStaticFactory(TaxedPriceFactory $factory)
    {
        self::$staticFactory = $factory;
    }

    /**
     * Only really intended for testing.
     */
    public static function clearStaticFactory()
    {
        self::$staticFactory = null;
    }

    /**
     * @return Factory
     */
    public static function getStaticFactory()
    {
        self::assertStaticFactoryHasBeenCreated();

        return self::$staticFactory;
    }

    /**
     * staticCreateTaxedPrice
     *
     * @param Money|float $amount
     * @param Money|float $tax
     * @param string      $currency
     *
     * @return TaxedPrice
     */
    public static function staticCreate($amount, $tax, $currency = null)
    {
        self::assertStaticFactoryHasBeenCreated();

        return self::$staticFactory->createTaxedPrice($amount, $tax, $currency);
    }

    private static function assertStaticFactoryHasBeenCreated()
    {
        if (!self::$staticFactory) {
            self::$staticFactory = self::createDefaultInstance();
        }
    }
}
{'fraction_non_alphanumeric': 0.1161262050832603, 'fraction_numerical': 0.0, 'mean_word_length': 2.3764792899408285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '396424', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1240, 'n_words': 257}