PayPal\Core\PayPalCredentialManager::initCredential PHP Method

initCredential() private method

Load credentials for multiple accounts, with priority given to Signature credential.
private initCredential ( array $config )
$config array
    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 . ".ClientId"]) && isset($credArr[$key . ".ClientSecret"])) {
                $userName = $key;
                $this->credentialHashmap[$userName] = new OAuthTokenCredential($credArr[$key . ".ClientId"], $credArr[$key . ".ClientSecret"]);
            }
            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;
        }
    }