limitCollection.

@param array $data
@return array
436305
protected function limitCollection($data)
    {
        $results = [];
        foreach ($data as $key => $value) {
            if (is_array($value) === true && count($value) > $this->limit) {
                $value = array_slice($value, 0, $this->limit);
            }

            if ($value instanceof Collection && $value->count() > $this->limit) {
                $value = $value->take($this->limit);
            }

            $results[$key] = $value;
        }

        return $results;
    }
698211
public function take($limit): CollectionInterface
    {
        if ($limit >= 0) {
            return $this->takeFirst($limit);
        } else {
            return $this->takeLast(abs($limit));
        }
    }
1068137
protected function convertToResource($data)
    {
        return Collection::make($this->client, $data->id)
            ->init($data);
    }
814809
public function loadCollection($data = null)
    {
        $this->beforeLoad();

        if ($this->collectionLoader instanceof Closure) {
            call_user_func($this->collectionLoader, $this, $data);
        } else {
            $this->collection->load($data);
        }
    }
1324378
public function set(array $data): CollectionInterface
    {
        foreach ($data as $row) {
            $this->add($row);
        }

        return $this;
    }
1096446
public static function roundCollection(array $data, $precision = 2)
    {
        $output = array();

        foreach ($data as $key => $value){
            $output[$key] = round($value, $precision);
        }

        return $output;
    }
629759
public function fill(array $data)
    {
        foreach ($data as $key => &$row) {
            $this->original = $value = array_get($row, $this->name);

            $value = $this->htmlEntityEncode($value);

            array_set($row, $this->name, $value);

            if ($this->isDefinedColumn()) {
                $this->useDefinedColumn();
            }

            if ($this->hasDisplayCallbacks()) {
                $value = $this->callDisplayCallbacks($this->original, $key);
                array_set($row, $this->name, $value);
            }
        }

        return $data;
    }
1241216
public static function requestApi(array $data): Collection
    {
        Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data));

        $data = array_filter($data, function ($value) {
            return ($value == '' || is_null($value)) ? false : true;
        });

        $result = mb_convert_encoding(self::$instance->post('', $data), 'utf-8', 'gb2312');

        $result = json_decode($result, true);

        Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Alipay', '', self::$instance->getBaseUri(), $result));

        return self::processingApiResult($data, $result);
    }
1016900
public function getTopThievesEntityData($limit = 10)
    {
        $topThieves = $this->gameDataService->getTopJobCharacter(2);

        return $topThieves->setMaxResults($limit)
            ->getQuery()
            ->getResult();
    }
431891
public function saveCollection($data): Collection
    {
        $items = collect();

        foreach ($data as $optionData) {
            $item = $this->save($optionData, (int) ($optionData['id'] ?? 0));

            $items->push($item);
        }

        return $items;
    }
321048
public function create(array $data = [])
    {
        $collection = parent::create($data);

        if ($this->getCurrentCategory() && $this->getCurrentCategory()->getLevel() >= 2) {
            $collection->addAttributeToFilter('entity_id', ['neq' => (int) $this->getCurrentCategory()->getId()]);

            $rootPath      = array_slice($this->getCurrentCategory()->getPathIds(), 0, 2);
            $pathCondition = implode('/', $rootPath) . '%';
            $collection->addFieldToFilter('path', ['like' => $pathCondition]);
        }

        return $collection;
    }
791159
public function limit($limit = null, $offset = null)
    {
        $this->results = $this->fetch($limit, $offset);

        return $this->results->fetchAll();
    }
769308
public function overwriteWith($data)
    {
        if (is_array($data)) {
            $this->data = $data + $this->data;
        } elseif ($data instanceof Collection) {
            $this->data = $data->toArray() + $this->data;
        } else {
            foreach ($data as $key => $value) {
                $this->data[$key] = $value;
            }
        }

        return $this;
    }
405144
public function create(array $data = [])
    {
        $collection = new Collection();

        if (array_key_exists('parts', $data)) {
            $collection->setParts(
                $this->getMovieFactory()->createCollection($data['parts'])
            );
        }

        if (array_key_exists('backdrop_path', $data)) {
            $collection->setBackdropImage(
                $this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
            );
        }

        if (array_key_exists('images', $data)) {
            $collection->setImages(
                $this->getImageFactory()->createCollectionFromMovie($data['images'])
            );
        }

        if (array_key_exists('poster_path', $data)) {
            $collection->setPosterImage(
                $this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
            );
        }

        return $this->hydrate($collection, $data);
    }
492711
public static function fromArray(array $data)
    {
        $models = collect($data)->map(function ($value) {
            if ($value instanceof Model) {
                return [$value];
            } elseif ($value instanceof EloquentCollection) {
                return $value->flatten();
            }
        })->collapse()->filter();

        return $models->map(function ($model) {
            return FormatModel::given($model);
        })->all();
    }
1180040
public function fromDbTableRows(Collection $data)
    {
        $iterator = new \ArrayIterator();
        foreach ($data as $item) {
            $iterator->append($this->fromDbTableRow($item));
        }

        return $iterator;
    }
227168
public function fill(array $data)
    {
        foreach ($data as $key => &$row) {
            $this->original = $value = Arr::get($row, $this->name);

            $value = $this->htmlEntityEncode($value);

            Arr::set($row, $this->name, $value);

            if ($this->isDefinedColumn()) {
                $this->useDefinedColumn();
            }

            if ($this->hasDisplayCallbacks()) {
                $value = $this->callDisplayCallbacks($this->original, $key);
                Arr::set($row, $this->name, $value);
            }
        }

        return $data;
    }