<commit_before><?php
/**
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2017 Foreach.Soft Ltd. (http://each.uz)
 */
declare(strict_types=1);

namespace Fes\Money;

use Assert\Assertion;
use Fes\Money\Currency\Currencies\Null;
use Fes\Money\Currency\CurrencyInterface;
use Fes\Money\Currency\HasStandardFormInterface;
use Fes\Money\Currency\NullCurrencyInterface;
use Fes\Money\Exception\DifferentCurrencyException;

class Money implements MoneyInterface
{
    /**
     * @var float
     */
    protected $amount;

    /**
     * @var CurrencyInterface
     */
    protected $currency;

    /**
     * Money constructor.
     *
     * @param float             $amount
     * @param CurrencyInterface $currency
     */
    public function __construct(float $amount, CurrencyInterface $currency)
    {
        $this->amount = $amount;
        $this->currency = $currency;
    }
    
    /**
     * @return Money
     */
    public static function null(): self
    {
        return new static(0, new Null());
    }
    
    /**
     * @return bool
     */
    public function isNull(): bool
    {
        return $this->amount == 0;
    }

    /**
     * @param Money $money
     * @return Money
     * @throws DifferentCurrencyException
     */
    public function add(self $money): self
    {
        if ($money->getCurrency() != $this->currency &&
            !$money instanceof NullCurrencyInterface &&
            !$this->currency instanceof NullCurrencyInterface
        ) {
            throw new DifferentCurrencyException();
        }

        return new static(
            $this->amount + $money->getAmount(),
            !$this->currency instanceof NullCurrencyInterface ? $this->currency : $money->currency
        );
    }

    /**
     * @param Money $money
     * @return Money
     * @throws DifferentCurrencyException
     */
    public function subtract(Money $money): Money
    {
        if ($money->getCurrency() != $this->currency &&
            !$money instanceof NullCurrencyInterface &&
            !$this->currency instanceof NullCurrencyInterface
        ) {
            throw new DifferentCurrencyException();
        }
    
        return new static(<commit_msg>Changed direct class name to self<commit_after><?php
/**
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2017 Foreach.Soft Ltd. (http://each.uz)
 */
declare(strict_types=1);

namespace Fes\Money;

use Assert\Assertion;
use Fes\Money\Currency\Currencies\Null;
use Fes\Money\Currency\CurrencyInterface;
use Fes\Money\Currency\HasStandardFormInterface;
use Fes\Money\Currency\NullCurrencyInterface;
use Fes\Money\Exception\DifferentCurrencyException;

class Money implements MoneyInterface
{
    /**
     * @var float
     */
    protected $amount;

    /**
     * @var CurrencyInterface
     */
    protected $currency;

    /**
     * Money constructor.
     *
     * @param float             $amount
     * @param CurrencyInterface $currency
     */
    public function __construct(float $amount, CurrencyInterface $currency)
    {
        $this->amount = $amount;
        $this->currency = $currency;
    }
    
    /**
     * @return Money
     */
    public static function null(): self
    {
        return new static(0, new Null());
    }
    
    /**
     * @return bool
     */
    public function isNull(): bool
    {
        return $this->amount == 0;
    }

    /**
     * @param Money $money
     * @return Money
     * @throws DifferentCurrencyException
     */
    public function add(self $money): self
    {
        if ($money->getCurrency() != $this->currency &&
            !$money instanceof NullCurrencyInterface &&
            !$this->currency instanceof NullCurrencyInterface
        ) {
            throw new DifferentCurrencyException();
        }

        return new static(
            $this->amount + $money->getAmount(),
            !$this->currency instanceof NullCurrencyInterface ? $this->currency : $money->currency
        );
    }

    /**
     * @param Money $money
     * @return Money
     * @throws DifferentCurrencyException
     */
    public function subtract(self $money): self
    {
        if ($money->getCurrency() != $this->currency &&
            !$money instanceof NullCurrencyInterface &&
            !$this->currency instanceof NullCurrencyInterface
        ) {
            throw new DifferentCurrencyException();
        }
    
        return new static(
{'fraction_non_alphanumeric': 0.11855203619909502, 'fraction_numerical': 0.003167420814479638, 'mean_word_length': 2.1714490674318507, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '2793585', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1202, 'n_words': 280}