lib/BlockCypher/Core/BlockCypherCredentialManager.php
private function initCredential($config)
    {
        $suffix = 1;
        $prefix = "acct";

        $arr = array();
        foreach ($config as $k => $v) {
            if (strstr($k, $prefix)) {
                $arr[$k] = $v;
            }
        }
        $credArr = $arr;

        $arr = array();
        foreach ($config as $key => $value) {
            $pos = strpos($key, '.');
            if (strstr($key, "acct")) {
                $arr[] = substr($key, 0, $pos);
            }
        }
        $arrayPartKeys = array_unique($arr);

        $key = $prefix . $suffix;
        $userName = null;
        while (in_array($key, $arrayPartKeys)) {
            if (isset($credArr[$key . ".AccessToken"]) && isset($credArr[$key . ".AccessToken"])) {
                $userName = $key;
                $this->credentialHashmap[$userName] = new SimpleTokenCredential($credArr[$key . ".AccessToken"]);
            }
            if ($userName && $this->defaultAccountName == null) {
                if (array_key_exists($key . '.UserName', $credArr)) {
                    $this->defaultAccountName = $credArr[$key . '.UserName'];
                } else {
                    $this->defaultAccountName = $key;
                }
            }
            $suffix++;
            $key = $prefix . $suffix;
        }

    }
private function initCredential($config)
    {
        $suffix = 1;
        $prefix = "acct";

        $arr = array();
        foreach ($config as $k => $v) {
            if (strstr($k, $prefix)) {
                $arr[$k] = $v;
            }
        }
        $credArr = $arr;

        $arr = array();
        foreach ($config as $key => $value) {
            $pos = strpos($key, '.');
            if (strstr($key, "acct")) {
                $arr[] = substr($key, 0, $pos);
            }
        }
        $arrayPartKeys = array_unique($arr);

        $key = $prefix . $suffix;
        $userName = null;
        while (in_array($key, $arrayPartKeys)) {
            if (isset($credArr[$key . ".AccessToken"]) && isset($credArr[$key . ".AccessToken"])) {
                $userName = $key;
                $this->credentialHashmap[$userName] = new SimpleTokenCredential($credArr[$key . ".AccessToken"]);
            }
            if ($userName && $this->defaultAccountName == null) {
                if (array_key_exists($key . '.UserName', $credArr)) {
                    $this->defaultAccountName = $credArr[$key . '.UserName'];
                } else {
                    $this->defaultAccountName = $key;
                }
            }
            $suffix++;
            $key = $prefix . $suffix;
        }

    }
private function initCredential ( $ config ) { $ suffix = 1 ; $ prefix = "acct" ; $ arr = array ( ) ; foreach ( $ config as $ k => $ v ) { if ( strstr ( $ k , $ prefix ) ) { $ arr [ $ k ] = $ v ; } } $ credArr = $ arr ; $ arr = array ( ) ; foreach ( $ config as $ key => $ value ) { $ pos = strpos ( $ key , '.' ) ; if ( strstr ( $ key , "acct" ) ) { $ arr [ ] = substr ( $ key , 0 , $ pos ) ; } } $ arrayPartKeys = array_unique ( $ arr ) ; $ key = $ prefix . $ suffix ; $ userName = null ; while ( in_array ( $ key , $ arrayPartKeys ) ) { if ( isset ( $ credArr [ $ key . ".AccessToken" ] ) && isset ( $ credArr [ $ key . ".AccessToken" ] ) ) { $ userName = $ key ; $ this -> credentialHashmap [ $ userName ] = new SimpleTokenCredential ( $ credArr [ $ key . ".AccessToken" ] ) ; } if ( $ userName && $ this -> defaultAccountName == null ) { if ( array_key_exists ( $ key . '.UserName' , $ credArr ) ) { $ this -> defaultAccountName = $ credArr [ $ key . '.UserName' ] ; } else { $ this -> defaultAccountName = $ key ; } } $ suffix ++ ; $ key = $ prefix . $ suffix ; } }
Load credentials for multiple accounts, with priority given to Signature credential.

@param array $config
Load credentials for multiple accounts with priority given to Signature credential .