*
@param PagSeguroConnectionData $connectionData
@param $code
@return string
173507
private static function buildFindByDayIntervalUrl(PagSeguroConnectionData $connectionData, $interval)
    {
        $url = $connectionData->getWebserviceUrl() . $connectionData->getResource('findUrl') . 'notifications';
        return "{$url}?" . $connectionData->getCredentialsUrlQuery() . "&interval=" . $interval;
    }
250206
public function actionConnect($code)
    {

        $account = $this->finder->findAccount()->byCode($code)->one();

        if ($account === null || $account->getIsConnected()) {
            throw new NotFoundHttpException();
        }

        /** @var User $user */
        $user = \Yii::createObject([
            'class'    => User::className(),
            'scenario' => 'connect',
            'email'    => $account->email,
        ]);
        $profile = new Profile();

        $event = $this->getConnectEvent($account, $user);

        $this->trigger(self::EVENT_BEFORE_CONNECT, $event);

        if ($user->load(\Yii::$app->request->post())) {
            if($profile->load(\Yii::$app->request->post()) && $profile->validate()) {
                $user->username = $user->email;
                $user->password = Password::generate(8);
                if($profile->user_id = $user->register(Url::to(['/user/login', 'language' => Language::getCurrent()->lang_id], true))) {
                    $profile->save();

                    $this->trigger(self::EVENT_AFTER_REGISTER, new UserRegistrationEvent([
                        'id' => $profile->user_id
                    ]));

                    $account->connect($user);
                    $this->trigger(self::EVENT_AFTER_CONNECT, $event);
                    /*\Yii::$app->user->login($user, $this->module->rememberFor);
                    return $this->goBack();*/


                    Yii::$app->session->setFlash(
                        'info',
                        Yii::t(
                            'user',
                            'Your account has been created and a message with further instructions has been sent to your email'
                        )
                    );

                    return $this->render('/message', [
                        'title'  => \Yii::t('user', 'Your account has been created'),
                        'module' => $this->module,
                        'profile' => $profile
                    ]);
                }
            }
        }

        return $this->render('connect', [
            'model'   => $user,
            'account' => $account,
            'profile' => $profile,
        ]);
    }
1169265
public function json($code, $msg = '', $data = null) {
        $result = json_encode(['code' => $code, 'msg' => $msg, 'data' => $data]);
        $this->contentType(self::TYPE_JSON);
        $this->_response->end($result);
    }
1202936
private static function buildInstallmentURL(
        PagSeguroConnectionData $connectionData,
        $amount,
        $cardBrand = null,
        $maxInstallmentNoInterest = null
    ){
        $url = $connectionData->getWebserviceUrl() . $connectionData->getResource('url');
        $stringBuilder = "&amount=" . $amount;
        $stringBuilder .= ($cardBrand == null) ? "" : "&cardBrand=" . $cardBrand;
        $stringBuilder .= ($maxInstallmentNoInterest == null) ? "" :
            "&maxInstallmentNoInterest=".$maxInstallmentNoInterest;
        return "{$url}/?" . $connectionData->getCredentialsUrlQuery() . $stringBuilder;
    }
802861
public function get($code = null): string
    {
        if (!$this->validate($code)) {
            throw new \InvalidArgumentException('Invalid code');
        }

        return isset(self::$codes[$code]) ? self::$codes[$code] : '';
    }
1224128
static function getConnection($connection_name = null) {
		if (null === $connection_name) {
			$keys = array_keys(self::$parameters);
			$connection_name = reset($keys);
		}

		if (!@$connection_name) {
			return null;
		}

		return self::connect($connection_name);
	}
1280209
private function getConnectionData(array $connection, $driver)
    {
        $connection = $this->replaceKeyIfExists($connection, 'database', $driver === 'pdo_sqlite' ? 'path' : 'dbname');
        $connection = $this->replaceKeyIfExists($connection, 'username', 'user');

        return array_merge($this->getFilteredConfig(), $connection);
    }
1114072
public function forceDisconnect($sessionId, $connectionId)
    {
        Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey);
        Validators::validateConnectionId($connectionId);

        return $this->client->forceDisconnect($sessionId, $connectionId);
    }
702384
public function getVersionMap($connectionPath)
    {
        $versions = [];

        $input = $this->_inputChannel->getInputStream($connectionPath);
        $contents = stream_get_contents($input);

        $discoveryInfo = Utilities::unserialize($contents);

        $endpoints = $discoveryInfo['RuntimeServerEndpoints']
            ['RuntimeServerEndpoint'];

        if (array_key_exists('@attributes', $endpoints)) {
            $endpoints = [];
            $endpoints[] = $discoveryInfo
                ['RuntimeServerEndpoints']['RuntimeServerEndpoint'];
        }

        foreach ($endpoints as $endpoint) {
            $versions[$endpoint['@attributes']['version']] = $endpoint
                ['@attributes']['path'];
        }

        return $versions;
    }
306681
protected static function getData($code) {
        if(preg_match('/^\[&([a-z\d+\/]+=*)\]$/i', $code, $matches) !== 1) {
            throw new ChatlinkFormatException("Chatcode does not match the expected format.");
        }

        $base64 = $matches[1];

        $data = [];
        foreach (str_split(base64_decode($base64)) as $char) {
            $data[] = ord($char);
        }

        return $data;
    }
686729
protected function onConnectionError($message, $code = null)
    {
        CommunicationException::handle(
            new ConnectionException($this, static::createExceptionMessage($message), $code)
        );
    }
22539
public function getContextually($option, ConnectionKey $connectionKey = null)
    {
        $original = $this->configuration->get($option);
        $connectionKey = $connectionKey ?: $this->connections->getCurrentConnectionKey();

        $contexts = ['stages', 'connections', 'servers'];
        foreach ($contexts as $context) {
            if ($contextual = $this->getForContext($option, $context, $original, $connectionKey)) {
                return $contextual;
            }
        }

        return $original;
    }
224790
public static function get($code, $data=null) {
    self::predefine();
    if (defined($code)) {
      $def = unserialize(constant($code));
      $error = new ApplicationError($def[0], $def[1], $def[2], $def[3], $data);
      return $error;
    }
    else {
      throw new IllegalArgumentException("The error code '".$code."' is not defined");
    }
  }
351833
private function close(ConnectionInterface $conn, $code = 400, array $additional_headers = []) {
        $response = new Response($code, array_merge([
            'X-Powered-By' => \Ratchet\VERSION
        ], $additional_headers));

        $conn->send(gPsr\str($response));
        $conn->close();
    }
723292
public function actionConnect($code) {
    $account = Account::find()->byCode($code)->one();

    if ($account === null || $account->getIsConnected()) {
      throw new NotFoundHttpException();
    }

    /** @var User $user */
    $user = Yii::createObject([
      'class' => User::className(),
      'scenario' => 'connect',
      'username' => $account->username,
      'email' => $account->email,
    ]);

    $event = $this->getConnectEvent($account, $user);

    $this->trigger(self::EVENT_BEFORE_CONNECT, $event);

    if ($user->load(Yii::$app->request->post()) && $user->create()) {
      $account->connect($user);
      $this->trigger(self::EVENT_AFTER_CONNECT, $event);
      Yii::$app->user->login($user, $this->module->rememberFor);
      return $this->goBack();
    }

    return $this->render('connect', [
      'model' => $user,
      'account' => $account,
    ]);
  }
1089607
protected function chooseConnectionConfiguration($connectionName, $params)
    {
        if ($connectionName === 'master') {
            return $params['master'];
        }

        $config = $params['slaves'][array_rand($params['slaves'])];

        if (! isset($config['charset']) && isset($params['master']['charset'])) {
            $config['charset'] = $params['master']['charset'];
        }

        return $config;
    }
920610
public function getRelatedName($reference, $code = true)
    {
        return $this->isMultiReferences($reference) ? $this->formatRelatedName($reference->getLocal()->getColumnName(), $code) : '';
    }