User-agent

@param array $array
@return string[]
509622
private function buildUserAgent($array)
    {
        $result = [];
        foreach ($array as $userAgent => $rules) {
            $rules = $this->arrayMergeRecursiveEx(self::TEMPLATE_SUB, $rules);
            $result = array_merge(
                $result,
                [self::DIRECTIVE_USER_AGENT . ':' . $userAgent],
                $this->buildString($rules[self::DIRECTIVE_ROBOT_VERSION], self::DIRECTIVE_ROBOT_VERSION),
                $this->buildVisitTime($rules[self::DIRECTIVE_VISIT_TIME]),
                $this->buildArray($rules[self::DIRECTIVE_NO_INDEX], self::DIRECTIVE_NO_INDEX),
                $this->buildArray($rules[self::DIRECTIVE_DISALLOW], self::DIRECTIVE_DISALLOW),
                $this->buildArray($rules[self::DIRECTIVE_ALLOW], self::DIRECTIVE_ALLOW),
                $this->buildString($rules[self::DIRECTIVE_CRAWL_DELAY], self::DIRECTIVE_CRAWL_DELAY),
                $this->buildString($rules[self::DIRECTIVE_CACHE_DELAY], self::DIRECTIVE_CACHE_DELAY),
                $this->buildRequestRate($rules[self::DIRECTIVE_REQUEST_RATE]),
                $this->buildArray($rules[self::DIRECTIVE_COMMENT], self::DIRECTIVE_COMMENT)
            );
        }
        return $result;
    }
1116362
private function recursiveWalk($array) {
    foreach ($array as $k => $v) {
        if (is_array($v)) {
            $array[$k] = self::recursiveWalk($v);
        } else {
            $array[$k] = self::compareReplaceFaker($v);
        }
    }
    return $array;
  }
1163230
public function insertAll($array)
    {
        $ids = array();
        foreach ($array as $hash) {
            $ids[] = $this->del('set')->set($hash)->insert();
        }

        return $ids;
    }
917838
public function quoteArray(array $array): array
    {
        if (empty($array)) {
            return [];
        }
        foreach ($array as $key => $value) {
            if ($value instanceof RawExp) {
                $array[$key] = $value->getValue();
                continue;
            }

            $array[$key] = $this->quoteValue($value);
        }

        return $array;
    }
246569
protected static function prepareArrayLines(array $array)
    {
        $isAssoc = Arr::isAssoc($array);

        array_walk($array, function (&$value, $index, $withIndexes = false) {
            if (is_array($value)) {
                $value = self::formatArray($value);
            } else {
                $value = self::formatScalar($value);
            }

            if ($withIndexes) {
                $value = self::formatScalar($index) . ' => ' . $value;
            }
        }, $isAssoc);

        return $array;
    }
1016739
public static function randomize(array $array): array
    {
        for ($i = 0, $c = count($array); $i < $c - 1; $i++) {
            $j = rand($i + 1, $c - 1);
            list($array[$i], $array[$j]) = [$array[$j], $array[$i]];
        }

        return $array;
    }
680481
public static function convertStringToValueArray(array $array): array
    {

        foreach ($array as $i => $attr)
            $array[$i] = (is_array($attr) ? self::convertStringToValueArray($attr) : self::convertStringToValues($attr));

        return $array;
    }
1078802
public static function getListFromArray(array $array) {
		$n=count($array);
		switch ($n) {
			case 0:
				return '';
			case 1:
				return $array[0];
			default:
				return implode(
						/* I18N: list separator */ I18N::translate(', '), 
						array_slice($array, 0, $n-1)
					) .
					/* I18N: last list separator, " and " in English, " et " in French  */ I18N::translate(' and ') . 
					$array[$n-1];
		}
	}
487492
private static function formatRequest(&$array)
    {
        if (!isset($array['buyer'])) {
            $array['buyer'] = array();
        }
        if (!isset($array['3DSecure'])) {
            $array['3DSecure'] = array();
        }
        if (!isset($array['bankAccountData'])) {
            $array['bankAccountData'] = array();
        }
        if (!isset($array['cancelURL']) || !strlen($array['cancelURL'])) {
            $array['cancelURL'] = null;
        }
        if (!isset($array['notificationURL']) || !strlen($array['notificationURL'])) {
            $array['notificationURL'] = null;
        }
        if (!isset($array['returnURL']) || !strlen($array['returnURL'])) {
            $array['returnURL'] = null;
        }
        if (!isset($array['languageCode']) || !strlen($array['languageCode'])) {
            $array['languageCode'] = null;
        }
        if (!isset($array['securityMode']) || !strlen($array['securityMode'])) {
            $array['securityMode'] = null;
        }
        if (!isset($array['billingAddress'])) {
            $array['billingAddress'] = array();
        }
        if (!isset($array['shippingAddress'])) {
            $array['shippingAddress'] = array();
        }
        if (!isset($array['owner'])) {
            $array['owner'] = array();
        }
        if (!isset($array['ownerAddress'])) {
            $array['ownerAddress'] = array();
        }
        if (!isset($array['contracts']) || !strlen($array['contracts'][0]) || !is_array($array['contracts'])) {
            $array['contracts'] = null;
        }
        if (!isset($array['secondContracts']) || !strlen($array['secondContracts'][0]) || !is_array($array['secondContracts'])) {
            $array['secondContracts'] = null;
        }
        if (!isset($array['walletContracts']) || !strlen($array['walletContracts'][0]) || !is_array($array['walletContracts'])) {
            $array['walletContracts'] = null;
        }
        if (!isset($array['customPaymentPageCode']) || !strlen($array['customPaymentPageCode'])) {
            $array['customPaymentPageCode'] = null;
        }
        if (!isset($array['customPaymentTemplateURL']) || !strlen($array['customPaymentTemplateURL'])) {
            $array['customPaymentTemplateURL'] = null;
        }
        if (!isset($array['recurring'])) {
            $array['recurring'] = array();
        }
        if (!isset($array['orderRef']) || !strlen($array['orderRef'])) {
            $array['orderRef'] = null;
        }
        if (!isset($array['orderDate']) || !strlen($array['orderDate'])) {
            $array['orderDate'] = null;
        }
        if (!isset($array['walletIds']) || !strlen($array['walletIds'][0] || !is_array($array['walletIds']))) {
            $array['walletIds'] = null;
        }
        if (!isset($array['merchantName'])) {
            $array['merchantName'] = null;
        }
        if (!isset($array['miscData'])) {
            $array['miscData'] = null;
        }
        if (!isset($array['subMerchant'])) {
            $array['subMerchant'] = array();
        }
        if (!isset($array['asynchronousRetryTimeout'])) {
            $array['asynchronousRetryTimeout'] = null;
        }
    }
202041
public function copyToArray(array &$array)
    {
        parent::copyToArray($array);

        $array['action']       = LanguageUtility::toString($this->action);
        $array['grantType']    = LanguageUtility::toString($this->grantType);
        $array['clientId']     = $this->clientId;
        $array['subject']      = $this->subject;
        $array['scopes']       = $this->scopes;
        $array['accessToken']  = $this->accessToken;
        $array['tokenType']    = $this->tokenType;
        $array['expiresIn']    = LanguageUtility::orZero($this->expiresIn);
        $array['expiresAt']    = LanguageUtility::orZero($this->expiresAt);
        $array['refreshToken'] = $this->refreshToken;
        $array['properties']   = LanguageUtility::convertArrayOfArrayCopyableToArray($this->properties);
    }
70213
private function getArray(Array_ $array)
    {
        $return = [];

        foreach ($array->items as $item) {
            if ($item->key === null) {
                $return[] = $this->getValue($item->value);
            } else {
                $return[$this->getValue($item->key)] = $this->getValue($item->value);
            }
        }

        return $return;
    }
1189624
public static function removeNull(array $array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_null($value)) {
                continue;
            }
            $result[$key] = $value;
        }
        return $result;
    }
312140
public function verifyEnrollment(array $array)
    {
        $this->formatRequest($array);
        $WSRequest = array(
            'payment'       => $this->payment($array['payment']),
            'card'          => $this->card($array['card']),
            'orderRef'      => $array['orderRef'],
            'userAgent'     => $array['userAgent'],
            'mdFieldValue'  => $array['mdFieldValue'],
            'walletId'      => $array['walletId'],
            'walletCardInd' => $array['walletCardInd'],
            'merchantName'  => $array['merchantName'],
            'returnURL'     => $array['returnURL']
        );
        if (isset($array['generateVirtualCvx'])) {
            $WSRequest['generateVirtualCvx'] = $array['generateVirtualCvx'];
        }
        return $this->webServiceRequest($array, $WSRequest, self::DIRECT_API, 'verifyEnrollment');
    }
971829
public function flatten(array $array)
    {
        $return = [];
        foreach ($array as $key => $value) {
            if (in_array($key, $this->exceptions)) {
                $return[$key] = $value;
            } else {
                $return[] = $value;
            }
        }

        return $return;
    }
251766
public function parse(array $item): array
    {
        unset($item['permissions'], $item['groups']);
        $item['pending'] = true;

        $user = new User($item);

        $user->username = $item['email'];

        return [$user, $user->getErrors()];
    }
1221325
public static function append_config(array $array): array
    {
        $start = 9999;

        foreach ($array as $key => $value) {
            if (is_numeric($key)) {
                $start++;

                $array[$start] = Arr::pull($array, $key);
            }
        }

        return $array;
    }
301037
public static function associativeArray(array $array) {
        $string = '[ ';
        foreach($array as $key => $item) {
            $string .= $key . ' => ' . $item;
            if($item !== last($array)) {
                $string .= ', ';
            }
        }
        $string .= ' ]';

        return $string;
    }