<commit_before><?php

/**
 *  ____  _ _    ____      ____  ____  _  __
 * | __ )(_) |_ / ___| ___/ ___||  _ \| |/ /
 * |  _ \| | __| |  _ / _ \___ \| | | | ' / 
 * | |_) | | |_| |_| | (_) |__) | |_| | . \ 
 * |____/|_|\__|\____|\___/____/|____/|_|\_\                                         
 *
 * @package BitGoSDK PHP
 * @author  <NAME> <<EMAIL>>
 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3
 * @version 2.1
 */

namespace neto737\BitGoSDK;

use neto737\BitGoSDK\Enum\CurrencyCode;
use neto737\BitGoSDK\Enum\AddressType;

class BitGoSDK {

    const BITGO_PRODUCTION_API_ENDPOINT = 'https://www.bitgo.com/api/v2/';
    const BITGO_TESTNET_API_ENDPOINT = 'https://test.bitgo.com/api/v2/';

    private $APIEndpoint = null;
    private $AuthAPIEndpoint = null;
    private $url = null;
    private $params = [];
    private $allowedCoins = ['btc', 'bch', 'bsv', 'btg', 'eth', 'dash', 'ltc', 'xrp', 'zec', 'rmg', 'erc', 'omg', 'zrx', 'fun', 'gnt', 'rep', 'bat', 'knc', 'cvc', 'eos', 'qrl', 'nmr', 'pay', 'brd', 'tbtc', 'tbch', 'tbsv', 'teth', 'tdash', 'tltc', 'txrp', 'tzec', 'trmg', 'terc'];
    public $walletId = null;
    private $requestIP = null;

    /**
     * BitGoSDK Initialization
     * 
     * @param string $accessToken   Set your Access Token (API Key)
     * @param string $coin          Select the coin what you want to use with the BitGOSDK (use CurrencyCode class to select)
     * @param bool $testNet         Start instance as testnet (true or false), default is false
     * @throws \Exception
     */
    public function __construct(string $accessToken, string $coin = CurrencyCode::BITCOIN, bool $testNet = false) {
        $this->accessToken = $accessToken;
        $this->coin = $coin;
        $this->testNet = $testNet;
        $this->APIEndpoint = (!$this->testNet) ? self::BITGO_PRODUCTION_API_ENDPOINT . $this->coin : self::BITGO_TESTNET_API_ENDPOINT . $this->coin;
        $this->AuthAPIEndpoint = (!$this->testNet) ? self::BITGO_PRODUCTION_API_ENDPOINT : self::BITGO_TESTNET_API_ENDPOINT;

        if (!in_array($this->coin, $this->allowedCoins)) {
            throw new \Exception('You are trying to use an invalid coin');
        }
    }

    /**
     * Set the IP that will make requests on BitGo servers (useful feature to people who uses shared hosting)
     * 
     * @param string $ipAddress
     */
    public function setRequestIP(string $ipAddress) {
        if (filter_var($ipAddress, FILTER_VALIDATE_IP)) {
            $this->requestIP = $ipAddress;
        }
    }

    /**
     * Converts value in satoshi to BTC value
     * 
     * @param int $amount   amount in satoshi that you want to convert to BTC
     * @return float        value converted to BTC
     */
    public static function toBTC(int $amount) {
        return (float) sprintf('%.8f', bcdiv($amount, 100000000, 8));<commit_msg>Update BitGoSDK.php<commit_after><?php

/**
 *  ____  _ _    ____      ____  ____  _  __
 * | __ )(_) |_ / ___| ___/ ___||  _ \| |/ /
 * |  _ \| | __| |  _ / _ \___ \| | | | ' / 
 * | |_) | | |_| |_| | (_) |__) | |_| | . \ 
 * |____/|_|\__|\____|\___/____/|____/|_|\_\                                         
 *
 * @package BitGoSDK PHP
 * @author  <NAME> <<EMAIL>>
 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3
 * @version 2.1
 */

namespace neto737\BitGoSDK;

use neto737\BitGoSDK\Enum\CurrencyCode;
use neto737\BitGoSDK\Enum\AddressType;

class BitGoSDK {

    const BITGO_PRODUCTION_API_ENDPOINT = 'https://www.bitgo.com/api/v2/';
    const BITGO_TESTNET_API_ENDPOINT = 'https://test.bitgo.com/api/v2/';

    private $APIEndpoint = null;
    private $AuthAPIEndpoint = null;
    private $url = null;
    private $params = [];
    private $allowedCoins = ['btc', 'bch', 'bsv', 'btg', 'eth', 'dash', 'ltc', 'xrp', 'zec', 'rmg', 'erc', 'omg', 'zrx', 'fun', 'gnt', 'rep', 'bat', 'knc', 'cvc', 'eos', 'qrl', 'nmr', 'pay', 'brd', 'tbtc', 'tbch', 'tbsv', 'teth', 'tdash', 'tltc', 'txrp', 'tzec', 'trmg', 'terc'];
    public $walletId = null;
    private $requestIP = null;

    /**
     * BitGoSDK Initialization
     * 
     * @param string $accessToken   Set your Access Token (API Key)
     * @param string $coin          Select the coin what you want to use with the BitGOSDK (use CurrencyCode class to select)
     * @param bool $testNet         Start instance as testnet (true or false), default is false
     * @throws \Exception
     */
    public function __construct(string $accessToken, string $coin = CurrencyCode::BITCOIN, bool $testNet = false) {
        $this->accessToken = $accessToken;
        $this->coin = $coin;
        $this->testNet = $testNet;
        $this->APIEndpoint = (!$this->testNet) ? self::BITGO_PRODUCTION_API_ENDPOINT . $this->coin : self::BITGO_TESTNET_API_ENDPOINT . $this->coin;
        $this->AuthAPIEndpoint = (!$this->testNet) ? self::BITGO_PRODUCTION_API_ENDPOINT : self::BITGO_TESTNET_API_ENDPOINT;

        if (!in_array($this->coin, $this->allowedCoins)) {
            throw new \Exception('You are trying to use an invalid coin');
        }
    }

    /**
     * Set the IP that will make requests on BitGo servers (useful feature to people who uses shared hosting)
     * 
     * @param string $ipAddress
     */
    public function setRequestIP(string $ipAddress) {
        if (filter_var($ipAddress, FILTER_VALIDATE_IP)) {
            $this->requestIP = $ipAddress;
        }
    }

    /**
     * Converts value in satoshi to BTC value
     * 
     * @param int $amount   amount in satoshi that you want to convert to BTC
     * @return float        value converted to BTC
     */
    public static function toBTC(int $amount) {
        return sprintf('%.8f', bcdiv($amount, 100000000, 8));
{'fraction_non_alphanumeric': 0.1562391379909628, 'fraction_numerical': 0.009384775808133473, 'mean_word_length': 2.637800252844501, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2080533', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1936, 'n_words': 467}