Download the PHP package hectororm/collection without Composer

On this page you can find all versions of the php package hectororm/collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package collection

Hector Collection

Latest Version Software license Build Status Quality Grade Total Downloads

Hector Collection is the module of Hector ORM. Can be used independently of ORM.

Installation

Composer

You can install Hector Collection with Composer, it's the recommended installation.

Dependencies

Usage

Collection can be view like an array. But you don't call array_*() functions but directly methods of collection.

The collections implement CollectionInterface, only Collection is countable.

Available collections:

CollectionInterface methods

CollectionInterface::new(Closure|iterable $iterable): static

Create new instance of current collection.

Collection::count(): int

Count number of items in collection.

For lazy collection, all iterator is traversed.

Similar to count() function.

CollectionInterface::getArrayCopy(): array

Use method to get the array representation of your collection.

CollectionInterface::all(): array

Use method to get all values of your collection as array.

CollectionInterface::isEmpty(): bool

Know if collection is empty.

CollectionInterface::isList(): bool

Know if collection is list.

CollectionInterface::collect(): self

Collect all data from current collection into another one.

For lazy collection, collect all remaining items into classic collection.

CollectionInterface::sort(callable|int|null $callback = null): static

Sort items of collection.

Similar to PHP array sort functions.

CollectionInterface::multiSort(callable ...$callback): static

Multi sort items of collection.

CollectionInterface::filter(?callable $callback = null): static

Filter items with callback.

Similar to array_filter() function.

CollectionInterface::filterInstanceOf(string|object ...$class): static

Filter items with object instance comparison.

Similar to is_a() function.

CollectionInterface::map(callable $callback): static

Apply callback on items and return result of callback.

Similar to array_map() function.

CollectionInterface::each(callable $callback): static

Apply callback on items and return items.

Similar to array_walk() function.

CollectionInterface::search(callable|mixed $needle): int|string|false

Search key of item with callback or value.

Similar to array_search() function.

CollectionInterface::get(int $index = 0): mixed

Get item at index.

Negative index, starts at end of collection.

CollectionInterface::first(?callable $callback = null): mixed

Search first item.

If callback given, search first item whose respect callback.

CollectionInterface::last()

Search last item.

If callback given, search first item whose respect callback.

CollectionInterface::slice(int $offset, int|null $length = null): static

Extract a slice of the collection.

Similar to array_slice() function.

CollectionInterface::contains(mixed $value, bool $strict = false): bool

Collection contains value?

Similar to in_array() function.

CollectionInterface::chunk(int $length): static

Chunk collection items into collection of fixed length.

Similar to array_chunk() function.

CollectionInterface::keys(): static

Get keys of collection items.

Similar to array_keys() function.

CollectionInterface::values(): static

Get values of collection items.

Similar to array_values() function.

CollectionInterface::unique(): static

Get uniques items of collection items.

Similar to array_unique() function.

CollectionInterface::flip(): static

Flip keys and values.

Similar to array_flip() function.

CollectionInterface::reverse(bool $preserve_keys = false): static

Reverse order of items.

Similar to array_reverse() function.

CollectionInterface::column(string|int|Closure|null $column_key, string|int|Closure|null $index_key = null): static

Get column value or reindex collection.

Similar to array_column() function.

CollectionInterface::rand(int $length = 1): static

Get random values of collection.

Similar to array_rand() function.

CollectionInterface::sum(): float|int

Get sum of values.

Similar to array_sum() function.

CollectionInterface::avg(): float|int

Get average of values.

CollectionInterface::median(): float|int

Get median of values.

CollectionInterface::variance(): float|int

Get population variance of values.

CollectionInterface::deviation(): float|int

Get population deviation of values.

CollectionInterface::reduce(callable $callback, mixed $initial = null): mixed

Reduce collection with callback and optional initial value.

Similar to array_reduce() function.

Collection methods

Collection class implement ArrayAccess interface to allow to manipulate collection like an array.

Collection::append(mixed ...$value): static

Append value(s) to collection.

Similar to array_push() function.

Collection::prepend()

Prepend value(s) to collection.

Similar to array_unshift() function.

Collection::lazy(): CollectionInterface

New lazy collection from current collection.

LazyCollection methods

Lazy collection use generators to improve performances. Usage of a collection is unique, but can be chained.


All versions of collection with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
berlioz/helpers Version ^1.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hectororm/collection contains the following files

Loading the files please wait ....