<commit_before><?php

namespace JMS\Payment\CoreBundle\Entity;

use JMS\Payment\CoreBundle\Model\CreditInterface;
use JMS\Payment\CoreBundle\Model\ExtendedDataInterface;
use JMS\Payment\CoreBundle\Model\FinancialTransactionInterface;
use JMS\Payment\CoreBundle\Model\PaymentInterface;

/*
 * Copyright 2010 <NAME> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class FinancialTransaction implements FinancialTransactionInterface
{
    private $credit;
    private $extendedData;
    private $extendedDataOriginal;
    private $id;
    private $payment;
    private $processedAmount;
    private $reasonCode;
    private $referenceNumber;
    private $requestedAmount;
    private $responseCode;
    private $state;
    private $createdAt;
    private $updatedAt;
    private $trackingId;
    private $transactionType;

    public function __construct()
    {
        $this->state = self::STATE_NEW;
        $this->createdAt = new \DateTime();
        $this->processedAmount = 0.0;
        $this->requestedAmount = 0.0;
    }

    public function getCredit()
    {
        return $this->credit;
    }

    public function getExtendedData()
    {
        if (null !== $this->extendedData) {
            return $this->extendedData;
        }

        if (null !== $this->payment) {
            return $this->payment->getPaymentInstruction()->getExtendedData();
        } else if (null !== $this->credit) {
            return $this->credit->getPaymentInstruction()->getExtendedData();
        }

        return null;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getPayment()
    {
        return $this->payment;
    }

    public function getProcessedAmount()
    {
        return $this->processedAmount;
    }

    public function getReasonCode()
    {
        return $this->reasonCode;
    }

    public function getReferenceNumber()
    {
        return $this->referenceNumber;
    }

    public function getRequestedAmount()
    {
        return $this->requestedAmount;
    }

    public function getResponseCode()
    {
        return $this->responseCode;
    }

    public function getState()
    {
        return $this->state;
    }

    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    public function getTrackingId()
    {
        return $this->trackingId;
    }

    public function getTransactionType()
    {
        return $this->transactionType;
    }

    public function onPostLoad()
    {
        if (null !== $this->extendedData) {
            $this->extendedDataOriginal = clone $this->extendedData;
        }
    }

    public function onPrePersist()
    {
        $this->updatedAt = new \DateTime;

        if (null !== $this->extendedData && false === $this->extendedData->equals($this->extendedDataOriginal)) {
            $this->extendedData = clone $this->extendedData;
        }
    }

    public function setCredit(CreditInterface $credit)
    {
        $this->credit = $credit;<commit_msg>Added extra check (for non null extended data) and changed coding style.<commit_after><?php

namespace JMS\Payment\CoreBundle\Entity;

use JMS\Payment\CoreBundle\Model\CreditInterface;
use JMS\Payment\CoreBundle\Model\ExtendedDataInterface;
use JMS\Payment\CoreBundle\Model\FinancialTransactionInterface;
use JMS\Payment\CoreBundle\Model\PaymentInterface;

/*
 * Copyright 2010 <NAME> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class FinancialTransaction implements FinancialTransactionInterface
{
    private $credit;
    private $extendedData;
    private $extendedDataOriginal;
    private $id;
    private $payment;
    private $processedAmount;
    private $reasonCode;
    private $referenceNumber;
    private $requestedAmount;
    private $responseCode;
    private $state;
    private $createdAt;
    private $updatedAt;
    private $trackingId;
    private $transactionType;

    public function __construct()
    {
        $this->state = self::STATE_NEW;
        $this->createdAt = new \DateTime();
        $this->processedAmount = 0.0;
        $this->requestedAmount = 0.0;
    }

    public function getCredit()
    {
        return $this->credit;
    }

    public function getExtendedData()
    {
        if (null !== $this->extendedData) {
            return $this->extendedData;
        }

        if (null !== $this->payment) {
            return $this->payment->getPaymentInstruction()->getExtendedData();
        } else if (null !== $this->credit) {
            return $this->credit->getPaymentInstruction()->getExtendedData();
        }

        return null;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getPayment()
    {
        return $this->payment;
    }

    public function getProcessedAmount()
    {
        return $this->processedAmount;
    }

    public function getReasonCode()
    {
        return $this->reasonCode;
    }

    public function getReferenceNumber()
    {
        return $this->referenceNumber;
    }

    public function getRequestedAmount()
    {
        return $this->requestedAmount;
    }

    public function getResponseCode()
    {
        return $this->responseCode;
    }

    public function getState()
    {
        return $this->state;
    }

    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    public function getTrackingId()
    {
        return $this->trackingId;
    }

    public function getTransactionType()
    {
        return $this->transactionType;
    }

    public function onPostLoad()
    {
        if (null !== $this->extendedData) {
            $this->extendedDataOriginal = clone $this->extendedData;
        }
    }

    public function onPrePersist()
    {
        $this->updatedAt = new \DateTime;

        if (null !== $this->extendedDataOriginal 
                 && null !== $this->extendedData 
                 && false === $this->extendedData->equals($this->extendedDataOriginal)) {
            $this->extendedData = clone $this->extendedData;
        }
    }

    public function setCredit(CreditInterface $credit)
    {
        $this->credit = $credit;
{'fraction_non_alphanumeric': 0.10522724170874846, 'fraction_numerical': 0.00327555616214003, 'mean_word_length': 2.5435203094777563, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1185939', 'n_tokens_mistral': 2058, 'n_tokens_neox': 1937, 'n_words': 520}