<commit_before><?php

namespace Omnipay\NetPay\Message;

use Guzzle\Http\Exception\BadResponseException;
use Omnipay\Common\CreditCard;

/**
 * NetPay Abstract Request
 */
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
{
    const OPERATION_MODE_LIVE = 1;
    const OPERATION_MODE_TEST = 2;

    const TRANSACTION_SOURCE_INTERNET = 'INTERNET';
    const TRANSACTION_SOURCE_MOTO = 'MOTO';

    const PAYMENT_SOURCE_TYPE_CARD = 'CARD';
    const PAYMENT_SOURCE_TYPE_TOKEN = 'TOKEN';

    protected $cardTypes = [
        CreditCard::BRAND_VISA => 'VISA',
        CreditCard::BRAND_MASTERCARD => 'MCRD',
        CreditCard::BRAND_MAESTRO => 'MSTO',
        CreditCard::BRAND_AMEX => 'AMEX',
        CreditCard::BRAND_DINERS_CLUB => 'DINE',
    ];

    protected $operationType;

    protected $transactionSource = self::TRANSACTION_SOURCE_INTERNET;

    protected $paymentSourceType = self::PAYMENT_SOURCE_TYPE_CARD;

    public function getUsername()
    {
        return $this->getParameter('username');
    }

    public function setUsername($value)
    {
        return $this->setParameter('username', $value);
    }

    public function getPassword()
    {
        return $this->getParameter('password');
    }

    public function setPassword($value)
    {
        return $this->setParameter('password', $value);
    }

    public function getMerchantId()
    {
        return $this->getParameter('merchantId');
    }

    public function setMerchantId($value)
    {
        return $this->setParameter('merchantId', $value);
    }

    public function getSslKeyPath()
    {
        return $this->getParameter('sslKeyPath');
    }

    public function setSslKeyPath($value)
    {
        return $this->setParameter('sslKeyPath', $value);
    }

    public function getSslCertificatePath()
    {
        return $this->getParameter('sslCertificatePath');
    }

    public function setSslCertificatePath($value)
    {
        return $this->setParameter('sslCertificatePath', $value);
    }

    public function getSslKeyPassword()
    {
        return $this->getParameter('sslKeyPassword');
    }

    public function setSslKeyPassword($value)
    {
        return $this->setParameter('sslKeyPassword', $value);
    }

    public function setCardReference( $value )
    {
        $this->setPaymentSourceType( self::PAYMENT_SOURCE_TYPE_TOKEN );
        return parent::setCardReference( $value );
    }

    /**
     * @return string
     */
    public function getTransactionSource()
    {
        return $this->transactionSource;
    }

    /**
     * @param string $transactionSource
     * @throws \Exception
     */
    public function setTransactionSource($transactionSource)
    {
        if ( ! in_array( $transactionSource, [ self::TRANSACTION_SOURCE_INTERNET, self::TRANSACTION_SOURCE_MOTO ] ) )
        {
            throw new \Exception('Invalid transaction source supplied, must be one of " ' . implode('","', [ self::TRANSACTION_SOURCE_INTERNET, self::TRANSACTION_SOURCE_MOTO ] ) . '"');
        }
        $this->transactionSource = $transactionSource;
    }

    /**
     * @return string
     */
    public function getPaymentSourceType()<commit_msg>Only setting payment source type as token if card reference parameter not empty<commit_after><?php

namespace Omnipay\NetPay\Message;

use Guzzle\Http\Exception\BadResponseException;
use Omnipay\Common\CreditCard;

/**
 * NetPay Abstract Request
 */
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
{
    const OPERATION_MODE_LIVE = 1;
    const OPERATION_MODE_TEST = 2;

    const TRANSACTION_SOURCE_INTERNET = 'INTERNET';
    const TRANSACTION_SOURCE_MOTO = 'MOTO';

    const PAYMENT_SOURCE_TYPE_CARD = 'CARD';
    const PAYMENT_SOURCE_TYPE_TOKEN = 'TOKEN';

    protected $cardTypes = [
        CreditCard::BRAND_VISA => 'VISA',
        CreditCard::BRAND_MASTERCARD => 'MCRD',
        CreditCard::BRAND_MAESTRO => 'MSTO',
        CreditCard::BRAND_AMEX => 'AMEX',
        CreditCard::BRAND_DINERS_CLUB => 'DINE',
    ];

    protected $operationType;

    protected $transactionSource = self::TRANSACTION_SOURCE_INTERNET;

    protected $paymentSourceType = self::PAYMENT_SOURCE_TYPE_CARD;

    public function getUsername()
    {
        return $this->getParameter('username');
    }

    public function setUsername($value)
    {
        return $this->setParameter('username', $value);
    }

    public function getPassword()
    {
        return $this->getParameter('password');
    }

    public function setPassword($value)
    {
        return $this->setParameter('password', $value);
    }

    public function getMerchantId()
    {
        return $this->getParameter('merchantId');
    }

    public function setMerchantId($value)
    {
        return $this->setParameter('merchantId', $value);
    }

    public function getSslKeyPath()
    {
        return $this->getParameter('sslKeyPath');
    }

    public function setSslKeyPath($value)
    {
        return $this->setParameter('sslKeyPath', $value);
    }

    public function getSslCertificatePath()
    {
        return $this->getParameter('sslCertificatePath');
    }

    public function setSslCertificatePath($value)
    {
        return $this->setParameter('sslCertificatePath', $value);
    }

    public function getSslKeyPassword()
    {
        return $this->getParameter('sslKeyPassword');
    }

    public function setSslKeyPassword($value)
    {
        return $this->setParameter('sslKeyPassword', $value);
    }

    public function setCardReference( $value )
    {
        if ( ! empty( $value ) )
        {
            $this->setPaymentSourceType( self::PAYMENT_SOURCE_TYPE_TOKEN );
        }
        return parent::setCardReference( $value );
    }

    /**
     * @return string
     */
    public function getTransactionSource()
    {
        return $this->transactionSource;
    }

    /**
     * @param string $transactionSource
     * @throws \Exception
     */
    public function setTransactionSource($transactionSource)
    {
        if ( ! in_array( $transactionSource, [ self::TRANSACTION_SOURCE_INTERNET, self::TRANSACTION_SOURCE_MOTO ] ) )
        {
            throw new \Exception('Invalid transaction source supplied, must be one of " ' . implode('","', [ self::TRANSACTION_SOURCE_INTERNET, self::TRANSACTION_SOURCE_MOTO ] ) . '"');
        }
        $this->transactionSource = $transactionSource;
    }

    /**
     * @return string
     */
    public function getPaymentSourceType()
{'fraction_non_alphanumeric': 0.11450498848810438, 'fraction_numerical': 0.0006139677666922486, 'mean_word_length': 2.9926470588235294, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '102768', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1883, 'n_words': 350}