@param array $array

@return OrderItem
354581
protected function doCreateObject(array $array)
    {
        $orderItem = new OrderItem(isset($array['attributes']) && is_array($array['attributes']) ? $array['attributes'] : $array);
        if (isset($array['relationships']['products'])) {
            $mapper = new ProductsMapper();
            foreach ($array['relationships']['products'] as $item) {
                $product            = array_merge($item['attributes'], $item['relationships']);
                $orderItem->product = $mapper->createObject($product);
            }
        }

        // old structure
        if (isset($array['products'][0])) {
            if (isset($array['images'])) {
                $array['products'][0]['images'] = $array['images'];
            }
            $productMapper      = new ProductsMapper();
            $orderItem->product = $productMapper->createObject($array['products'][0]);
        }

        return $orderItem;
    }
948047
protected function serializeArray(array $array) {
        $data = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $data[$key] = $this->serializeArray($value);
            } else {
                $data[$key] = $this->serializeItem($value);
            }
        }

        return $data;
    }
536286
public static function orderArray($array, $order)
    {
        $ordered = [];

        foreach ($order as $key) {
            if (array_key_exists($key, $array)) {
                $ordered[$key] = $array[$key];
            }
        }

        return $ordered;
    }
320456
public static function createFromArray(array $array): self
    {
        $config = new self(
            ($array['language'] ?? null),
            ($array['store_searchable_metadata'] ?? true)
        );

        $config->synonyms = array_map(function (array $synonym) {
            return Synonym::createFromArray($synonym);
        }, $array['synonyms'] ?? []);
        $config->shards = (int) ($array['shards'] ?? self::DEFAULT_SHARDS);
        $config->replicas = (int) ($array['replicas'] ?? self::DEFAULT_REPLICAS);

        return $config;
    }
1004753
protected function card(array $array)
    {
        $card = new Card();
        if ($array) {
            foreach ($array as $k => $v) {
                if (array_key_exists($k, $card) && (strlen($v))) {
                    $card->$k = $v;
                }
            }
        }
        $card->paymentData = null;
        if (isset($array['paymentData'])) {
            $card->paymentData = $this->paymentData($array['paymentData']);
        }
        return new \SoapVar($card, SOAP_ENC_OBJECT, self::SOAP_CARD, self::PAYLINE_NAMESPACE);
    }
253766
private function serializeArrayOrTable(array $array)
    {
        $assoc = false;
        $index = 0;
        $values = [];

        foreach ($array as $key => $value) {
            // We already know the array is associative, serialize both the key
            // and the value ...
            if ($assoc) {
                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                // Otherwise, if the key matches the index counter it is sequential,
                // only serialize the value ...
            } elseif ($key === $index++) {
                $values[] = $this->serializeField($value);

                // Otherwise, we've just discovered the array is NOT sequential,
                // Go back through the existing values and add the keys ...
            } else {
                foreach ($values as $k => $v) {
                    $values[$k] = $this->serializeShortString($k) . $v;
                }

                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                $assoc = true;
            }
        }

        return ($assoc ? 'F' : 'A') . $this->serializeByteArray(
                implode('', $values)
            );
    }
183436
public static function createFromArray(array $array)
    {
        $scoreStrategy = new self();
        $scoreStrategy->type = $array['type'] ?: self::DEFAULT_TYPE;
        $scoreStrategy->configuration = $array['configuration'] ?? [];
        $scoreStrategy->weight = $array['weight'] ?? self::DEFAULT_WEIGHT;
        $scoreStrategy->scoreMode = $array['score_mode'] ?? self::SCORE_MODE_AVG;
        $scoreStrategy->filter = is_array($array['filter'])
            ? Filter::createFromArray($array['filter'])
            : null;

        return $scoreStrategy;
    }
381666
protected function doCreateObject(array $array)
    {
        $this->data        = $array;
        $this->entityGroup = new EntityGroup($this->data);
        $this->setMedia()
             ->setAttributes();

        return $this->entityGroup;
    }
96430
private static function sortByWeights(array &$array) {
    uasort($array, function ($a, $b) {
      $a_weight = isset($a['weight']) ? $a['weight'] : 0;
      $b_weight = isset($b['weight']) ? $b['weight'] : 0;

      if ($a_weight == $b_weight) {
        return ($a['label'] > $b['label']) ? 1 : -1;
      }
      return ($a_weight > $b_weight) ? 1 : -1;
    });
  }
1078684
private function kSortRecursive(array &$array)
    {
        foreach ($array as &$current) {
            if (is_array($current) &&
                $this->kSortRecursive($current) === false
            ) {
                return false;
            }
        }
        return ksort($array);
    }
1111964
public function doImmediateWalletPayment(array $array)
    {
        $this->formatRequest($array);
        $WSRequest = array(
            'payment'                => $this->payment($array['payment']),
            'order'                  => $this->order($array['order']),
            'buyer'                  => $this->buyer($array['buyer'], $array['shippingAddress'], $array['billingAddress']),
            'walletId'               => $array['walletId'],
            'cardInd'                => $array['cardInd'],
            'cvx'                    => $array['walletCvx'],
            'privateDataList'        => $this->privateData,
            'authentication3DSecure' => $this->authentication3DSecure($array['3DSecure']),
            'subMerchant'            => $this->subMerchant($array['subMerchant'])
        );
        return $this->webServiceRequest($array, $WSRequest, self::DIRECT_API, 'doImmediateWalletPayment');
    }
1040187
public function fromArray($array) {
		$array=parent::fromArray($array);
		foreach ( $array as $key => $value ) {
			$this->setProperty($key, $value);
		}
		return $array;
	}
1185401
public static function createFromArray(array $array): self
    {
        $query = isset($array['coordinate'])
            ? self::createLocated(
                Coordinate::createFromArray($array['coordinate']),
                $array['q'] ?? '',
                (int) ($array['page'] ?? self::DEFAULT_PAGE),
                (int) ($array['size'] ?? self::DEFAULT_SIZE)
            )
            : self::create(
                $array['q'] ?? '',
                (int) ($array['page'] ?? self::DEFAULT_PAGE),
                (int) ($array['size'] ?? self::DEFAULT_SIZE)
            );
        $query->fields = $array['fields'] ?? [];
        $query->aggregations = array_map(function (array $aggregation) {
            return Aggregation::createFromArray($aggregation);
        }, $array['aggregations'] ?? []);

        $query->sortBy = SortBy::createFromArray($array['sort'] ?? []);
        $query->filters = array_merge(
            $query->filters,
            array_map(function (array $filter) {
                return Filter::createFromArray($filter);
            }, $array['filters'] ?? [])
        );
        $query->universeFilters = array_merge(
            $query->universeFilters,
            array_map(function (array $filter) {
                return Filter::createFromArray($filter);
            }, $array['universe_filters'] ?? [])
        );
        $query->resultsEnabled = $array['results_enabled'] ?? true;
        $query->suggestionsEnabled = $array['suggestions_enabled'] ?? false;
        $query->aggregationsEnabled = $array['aggregations_enabled'] ?? true;
        $query->highlightEnabled = $array['highlight_enabled'] ?? false;
        $query->itemsPromoted = array_values(array_map(function (array $itemUUID) {
            return ItemUUID::createFromArray($itemUUID);
        }, $array['items_promoted'] ?? []));
        $query->fuzziness = $array['fuzziness'] ?? null;
        $query->searchableFields = $array['searchable_fields'] ?? [];
        $query->scoreStrategies = isset($array['score_strategies'])
            ? ScoreStrategies::createFromArray($array['score_strategies'])
            : null;
        $query->minScore = $array['min_score'] ?? self::NO_MIN_SCORE;
        $query->metadata = $array['metadata'] ?? [];

        if (isset($array['user'])) {
            $query->user = User::createFromArray($array['user']);
        }

        $query->subqueries = array_map(function (array $query) {
            return Query::createFromArray($query);
        }, $array['subqueries'] ?? []);

        if (isset($array['uuid'])) {
            $query->UUID = $array['uuid'];
        }
        if (isset($array['index_uuid'])) {
            $query->indexUUID = IndexUUID::createFromArray($array['index_uuid']);
        }

        return $query;
    }
1287529
public static function sortArrayByArray(array $array, array $orderArray)
    {
        $ordered = array();
        foreach ($orderArray as $key) {
            if (array_key_exists($key, $array)) {
                $ordered[$key] = $array[$key];
                unset($array[$key]);
            }
        }
        return $ordered + $array;
    }
1164492
public function arrayCopy(array $array)
    {
        $copy = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $copy[ $key ] = $this->arrayCopy($value);
            } elseif (is_object($value)) {
                $copy[ $key ] = clone $value;
            } else {
                $copy[ $key ] = $value;
            }
        }

        return $copy;
    }
157566
public static function flatten(array $array)
    {
        $out = [];

        foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $item) {
            if (is_int($key)) {
                $out[] = $item;
            } else {
                $out[$key] = $item;
            }
        }

        return $out;
    }
796388
protected function createFromArray($array)
    {
        $this->id = $array['id'];
        $this->modelType = $array['modelType'];
        $this->modelId = $array['modelId'];
        $this->name = $array['name'];
        $this->price = $array['price'];
        $this->image = $array['image'];
        $this->quantity = $array['quantity'];

        return $this;
    }