Generates a language mask from the given $languageSettings.

@param array $languageSettings

@return int
764981
protected function getLanguageMask(array $languageSettings)
    {
        $mask = 0;
        if ($languageSettings['useAlwaysAvailable']) {
            $mask |= 1;
        }

        foreach ($languageSettings['languages'] as $languageCode) {
            $mask |= $this->languageHandler->loadByLanguageCode($languageCode)->id;
        }

        return $mask;
    }
465963
public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) {
		if ( empty( $settings['singleCharacterWordSpacing'] ) ) {
			return;
		}

		// Add $next_character and $previous_character for context.
		$previous_character = DOM::get_prev_chr( $textnode );
		$next_character     = DOM::get_next_chr( $textnode );
		$node_data          = "{$previous_character}{$textnode->data}{$next_character}";
		$f                  = Strings::functions( $node_data );

		// Replace spaces.
		$node_data = \preg_replace( self::REGEX . $f['u'], '$1$2' . U::NO_BREAK_SPACE, $node_data );

		// If we have adjacent characters remove them from the text.
		$textnode->data = self::remove_adjacent_characters( $node_data, $f['strlen'], $f['substr'], $f['strlen']( $previous_character ), $f['strlen']( $next_character ) );
	}
253226
public function generateLanguageMaskFromLanguageIds(array $languageIds, $alwaysAvailable): int
    {
        // make sure alwaysAvailable part of bit mask always results in 1 or 0
        $languageMask = $alwaysAvailable ? 1 : 0;

        foreach ($languageIds as $languageId) {
            $languageMask |= $languageId;
        }

        return $languageMask;
    }
199450
protected function HLSetLangs($hlId, array $langs)
    {
        $hlId = (int) $hlId;
        if (!$hlId) {
            throw new Exception('Empty Hl id for langs');
        }

        $res = HighloadBlockLangTable::getList([
            'filter' => ['ID' => $hlId],
        ]);
        while ($loc = $res->fetch()) {
            HighloadBlockLangTable::delete($loc['ID']);
        }

        foreach ($langs as $langId => $langValue) {
            $langRes = HighloadBlockLangTable::add([
                'ID' => $hlId,
                'LID' => $langId,
                'NAME' => $langValue,
            ]);
            if (!$langRes->isSuccess()) {
                throw new Exception("Can't create lang {$langId} for {$hlId} highload block: " . implode(', ', $langRes->getErrorMessages()));
            }
        }
    }
262562
public function calculate(array $tokens)
    {
        foreach ($tokens as $idx => $token) {
            if ($token instanceof PotentialAbbreviationToken) {
                if ($this->abbreviations->hasAbbreviation($token->getValue())) {
                    $tokens[$idx] = new AbbreviationToken($token->getValue());
                }
            }
        }

        $probabilities = [];

        for ($i = 0, $c = count($tokens); $i < $c; $i++) {
            $token = $tokens[$i];
            $probability = new TokenProbability($token, 0);

            if ($this->rules->hasRule($token->getName())) {
                $patterns = $this->rules->getRule($token->getName())->getPatterns();

                foreach ($patterns as $pattern) {
                    $offsets = $pattern->getTokensOffsetRelativeToStartToken($token->getName());

                    foreach ($offsets as $offset => $expectedToken) {
                        if (!array_key_exists($i + $offset, $tokens)) {
                            continue 2;
                        }

                        $actualToken = $tokens[$i + $offset];

                        if ($actualToken->getName() !== $expectedToken->getTokenName()) {
                            continue 2;
                        }
                    }

                    $probability->setProbability($pattern->getProbability());
                }
            }

            $probabilities[] = $probability;
        }

        return $probabilities;
    }
660454
public function setBindings(array $bindings)
    {
        foreach ($bindings as $key => $binding) {
            if (0 < strpos($key, '$') && $key !== $k = preg_replace('/[ \t]*\$/', ' $', $key)) {
                unset($bindings[$key]);
                $bindings[$key = $k] = $binding;
            }
            if (!$binding instanceof BoundArgument) {
                $bindings[$key] = new BoundArgument($binding);
            }
        }

        $this->bindings = $bindings;

        return $this;
    }
735321
protected static function validateSettings($settings)
    {
        if (!isset($settings['consumerKey']) || !isset($settings['consumerSecret'])) {
            return false;
        }
        $settings['token'] = isset($settings['token']) ? $settings['token'] : null;
        $settings['tokenSecret'] = isset($settings['tokenSecret']) ? $settings['tokenSecret'] : null;

        return $settings;
    }
443588
public function getJavascript(&$javascripts, Settings $settings)
    {
        if ($this->linktype == LinkConstants::LINK_JAVASCRIPT) {
            $javascripts[$this->getIdType() . $settings->getPrefix() . $this->getId()] = $this->javascript;
        }
    }
54913
protected function validateDefaultLocalization($localizations)
    {
        $result = false;
        foreach ($localizations as $localization) {
            if ($localization->isDefault()) {
                if ($result) {
                    throw new InvalidDefaultLocalizationException();
                }
                $result = true;
            }
        }

        return $result;
    }
535088
private function _loadSettingsFromArray($settings)
    {
        if (isset($settings['sp'])) {
            $this->_sp = $settings['sp'];
        }
        if (isset($settings['idp'])) {
            $this->_idp = $settings['idp'];
        }

        $errors = $this->checkSettings($settings);
        if (empty($errors)) {
            $this->_errors = array();

            if (isset($settings['strict'])) {
                $this->_strict = $settings['strict'];
            }
            if (isset($settings['debug'])) {
                $this->_debug = $settings['debug'];
            }

            if (isset($settings['baseurl'])) {
                $this->_baseurl = $settings['baseurl'];
            }

            if (isset($settings['compress'])) {
                $this->_compress = $settings['compress'];
            }

            if (isset($settings['security'])) {
                $this->_security = $settings['security'];
            }

            if (isset($settings['contactPerson'])) {
                $this->_contacts = $settings['contactPerson'];
            }

            if (isset($settings['organization'])) {
                $this->_organization = $settings['organization'];
            }

            $this->_addDefaultValues();
            return true;
        } else {
            $this->_errors = $errors;
            return false;
        }
    }
407002
public function checkSettings($settings)
    {
        assert('is_array($settings)');

        if (!is_array($settings) || empty($settings)) {
            $errors = array('invalid_syntax');
        } else {
            $errors = array();
            if (!$this->_spValidationOnly) {
                $idpErrors = $this->checkIdPSettings($settings);
                $errors = array_merge($idpErrors, $errors);
            }
            $spErrors = $this->checkSPSettings($settings);
            $errors = array_merge($spErrors, $errors);

            $compressErrors = $this->checkCompressionSettings($settings);
            $errors = array_merge($compressErrors, $errors);
        }

        return $errors;
    }
116671
public function setSettings(array $settings) {
        $this->settings = $settings;

        $hosts = \ECL\Util::get($settings, 'hosts', []);
        $index_hosts = \ECL\Util::get($settings, 'index_hosts', []);
        $ssl_cert = \ECL\Util::get($settings, 'ssl_cert', null);
        $ssl_client_key = \ECL\Util::get($settings, 'ssl_client_key', null);
        $ssl_client_cert = \ECL\Util::get($settings, 'ssl_client_cert', null);

        if(count($index_hosts) == 0) {
            $index_hosts = $hosts;
        }

        $cb = \Elasticsearch\ClientBuilder::create();
        if(count($hosts)) {
            $cb->setHosts($hosts);
        }

        $icb = \Elasticsearch\ClientBuilder::create();
        if(count($index_hosts)) {
            $icb->setHosts($index_hosts);
        }

        if($ssl_cert !== null) {
            $cb->setSSLVerification($ssl_cert);
            $icb->setSSLVerification($ssl_cert);
        }
        if($ssl_client_key !== null && $ssl_client_cert !== null) {
            $cb->setSSLKey($ssl_client_key);
            $cb->setSSLCert($ssl_client_cert);
            $icb->setSSLKey($ssl_client_key);
            $icb->setSSLCert($ssl_client_cert);
        }

        $this->client = $cb->build();
        $this->index_client = $icb->build();
    }
188257
private function formatPreApprovalPaymentMethodData(array $paymentSettings)
    {
        $this->senderInfo['phone'] = [
            'areaCode' => $this->senderInfo['senderAreaCode'],
            'number'   => $this->senderInfo['senderPhone'],
        ];

        $this->creditCardHolder['phone'] = [
            'areaCode' => $this->creditCardHolder['creditCardHolderAreaCode'],
            'number'   => $this->creditCardHolder['creditCardHolderPhone'],
        ];

        $this->creditCardHolder['billingAddress'] = $this->billingAddress;

        if (!empty($this->senderInfo['senderCPF'])) {
            $this->senderInfo['documents'][0] = [
                'type'  => 'CPF',
                'value' => $this->senderInfo['senderCPF'],
            ];

            unset($this->senderInfo['senderCPF']);
        } else {
            $this->senderInfo['documents'][0] = [
                'type'  => 'CNPJ',
                'value' => $this->senderInfo['senderCNPJ'],
            ];

            unset($this->senderInfo['senderCNPJ']);
        }

        $this->creditCardHolder['documents'][0] = [
            'type'  => 'CPF',
            'value' => $this->creditCardHolder['creditCardHolderCPF'],
        ];

        unset($this->creditCardHolder['creditCardHolderCPF']);
        unset($this->senderInfo['senderAreaCode']);
        unset($this->senderInfo['senderPhone']);
        unset($this->creditCardHolder['creditCardHolderAreaCode']);
        unset($this->creditCardHolder['creditCardHolderPhone']);

        $data = [
            'type'          => $this->type,
            'sender'        => [
                'ip'         => $this->senderInfo['ip'],
                'hash'       => $this->senderInfo['hash'],
            ],
            'creditCard'    => [
                'token'          => $paymentSettings['creditCardToken'],
                'holder'         => $this->creditCardHolder,
            ],
        ];

        return $data;
    }
975371
public static function load(array $langs, $lang = null)
    {
        static::$langs = $langs;
        static::$lang = $lang ?: key($langs);
    }
763192
public static function createFromArray(array $data, SecuritySettingsInterface $sourceSettings = null)
    {
        if ($sourceSettings && !$sourceSettings instanceof self) {
            throw new \InvalidArgumentException('Provide an instance of DefaultSecuritySettings for $sourceSettings');
        }

        $settings = $sourceSettings ? clone $sourceSettings : new static();
        \assert($settings instanceof self);
        $settings->mergeSettings($data);

        return $settings;
    }
149555
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $settingKey => $settingValue) {
            switch ($settingKey) {
                case 'isMultiple':
                    if (!is_bool($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'bool',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'options':
                    if (!is_array($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'multilingualOptions':
                    if (!is_array($settingValue) && !is_array(reset($settingValue))) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                default:
                    $validationErrors[] = new ValidationError(
                        "Setting '%setting%' is unknown",
                        null,
                        array(
                            '%setting%' => $settingKey,
                        ),
                        "[$settingKey]"
                    );
            }
        }

        return $validationErrors;
    }
236128
protected function generateNamespaceContext(array & $tokens)
	{
		$namespaceContext = new NamespaceContext();
		
		for($size = count($tokens), $i = 0; $i < $size; $i++)
		{
			if(is_array($tokens[$i]))
			{
				switch($tokens[$i][0])
				{
					case T_NAMESPACE:
						
						$namespace = '';
						
						for($i++; $i < $size; $i++)
						{
							if(is_array($tokens[$i]))
							{
								switch($tokens[$i][0])
								{
									case T_WHITESPACE:
									case T_COMMENT:
									case T_DOC_COMMENT:
										continue 2;
									case T_NS_SEPARATOR:
									case T_STRING:
										$namespace .= $tokens[$i][1];
										continue 2;
								}
							}
							
							break;
						}
						
						$namespaceContext = new NamespaceContext($namespace);
						
						break;
					case T_USE:
						do
						{
							$i++;
							$this->readImport($tokens, $i, $namespaceContext);
						}
						while($tokens[$i] == ',');
						
						break;
					case T_CLASS:
					case T_INTERFACE:
					case T_TRAIT:
						// Abort namespace detection as soon as code declaring a type is reached.
						break 2;
				}
			}
		}
		
		return $namespaceContext;
	}