Download the PHP package omegaalfa/collection without Composer
On this page you can find all versions of the php package omegaalfa/collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download omegaalfa/collection
More information about omegaalfa/collection
Files in omegaalfa/collection
Download omegaalfa/collection
More information about omegaalfa/collection
Files in omegaalfa/collection
Vendor omegaalfa
Package collection
Short Description This library implements the Trie routing logic
License MIT
Package collection
Short Description This library implements the Trie routing logic
License MIT
Please rate this library. Is it a good library?
Informations about the package collection
# π PHP Collection Library
[](https://php.net/)
[](LICENSE)
[](tests/)
[](coverage/)
[](phpstan.neon)
**A powerful, type-safe PHP collection library with eager & lazy evaluation** π―
[Features](#-features) β’
[Installation](#-installation) β’
[Quick Start](#-quick-start) β’
[Documentation](#-documentation) β’
[Examples](#-examples)
β¨ Features
| ### π― **Type-Safe** Full PHPDoc generics support | ### β‘ **Lazy Evaluation** Memory-efficient processing | ### π **Immutable** Readonly data structures |
- β 7 Specialized Classes - Collection, Sequence, Map, LazySequence, LazyMap, LazyFileIterator, LazyProxyObject
- β 150+ Methods - Rich API with fluent interface
- β Modern PHP - PHP 8.3+ with strict types & readonly properties
- β Well Tested - 239 tests, 80.85% coverage
- β Zero Dependencies - Pure PHP, no external packages required
π¦ Installation
Requirements
| Requirement | Version | Note |
|---|---|---|
| PHP | >= 8.3 |
Required |
| PHP | >= 8.4 |
Recommended for LazyProxyObject |
π― Core Concepts
| Class | Type | Purpose | Use Case |
|---|---|---|---|
Collection |
Generic | Iterator wrapper with transformations | β Mixed data, legacy code, Iterator support |
Sequence |
Eager | Ordered immutable list | β Small lists, type safety, immutability |
Map |
Eager | Immutable key-value dictionary | β Small maps, type safety, immutability |
LazySequence |
Lazy | Generator-based pipeline | β Large datasets, streaming, memory efficiency |
LazyMap |
Lazy | Lazy value computation | β Expensive computations, caching, DI |
LazyFileIterator |
Lazy | File streaming (JSON lines) | β Large files, memory constraints |
LazyProxyObject |
Lazy | PHP 8.4+ lazy object instantiation | β Expensive objects, service containers |
οΏ½ Quick Start
π‘ Collection - Generic Wrapper
Click to expand
π Sequence - Ordered Immutable List
Click to expand
πΊοΈ Map - Immutable Key-Value Dictionary
Click to expand
β‘ LazySequence - Generator-Based Pipeline
Click to expand
π― LazyMap - Lazy Value Computation
Click to expand
π LazyFileIterator - Stream Large Files
Click to expand
π― Choosing the Right Class
| ### Use **Collection** π‘ - β Working with `Iterator` instances - β Need array-like access (`ArrayAccess`) - β Want both eager and lazy methods - β Migrating legacy code ### Use **Sequence** π - β Need ordered list (0-indexed) - β Want immutability - β Working with small-to-medium datasets - β Type safety is important ### Use **Map** πΊοΈ - β Need key-value pairs - β Want immutability - β Working with configuration, dictionaries - β Type safety is important | ### Use **LazySequence** β‘ - β Large datasets (millions of items) - β Memory is constrained - β Need pipeline composition - β Can benefit from short-circuit evaluation ### Use **LazyMap** π― - β Values are expensive to compute - β Not all values will be accessed - β Need lazy initialization - β Dependency injection containers ### Use **LazyFileIterator** π - β Processing large JSON line files - β Cannot load entire file in memory - β Streaming data processing |
οΏ½ API Reference
π₯ Core Methods - Quick Reference
### π Transformation ### π Aggregation ### π Retrieval ### β‘ Lazy Operationsπ Full Method Compatibility Matrix
| Method | Collection | Sequence | Map | LazySequence | LazyMap | |--------|:----------:|:--------:|:---:|:------------:|:-------:| | `map` | β | β | β | β | β | | `filter` | β | β | β | β | β | | `reduce` | β | β | β | β | β | | `take` | β | β | β | β | β | | `skip` | β | β | β | β | β | | `chunk` | β | β | β | β | β | | `sort` | β | β | β | β | β | | `reverse` | β | β | β | β | β | | `unique` | β | β | β | β | β | | `merge` | β | β | β | β | β | | `keys` | β | β | β | β | β | | `values` | β | β | β | β | β | | `mapKeys` | β | β | β | β | β | | `mapValues` | β | β | β | β | β |π Complete documentation: docs/API.md β’ 150+ methods documented
β‘ Performance & Optimization
πΎ Memory Efficiency
| #### Traditional Approach β **Result:** ~400 MB | ~850ms | #### Lazy Evaluation β **Result:** ~2 MB | ~0.7ms π **2290x FASTER!** |
π Benchmark Results
View Detailed Benchmarks
**Operation:** `map β filter β take(100)` | Implementation | Time | Memory | vs Array | |----------------|------|--------|----------| | Array | 850ms | 400 MB | baseline | | Collection | 820ms | 380 MB | 1.04x faster | | LazySequence | 12ms | 2 MB | **70x faster** | | LazyFileIterator | 8ms | 1 MB | **106x faster** |π― Lazy vs Eager Trade-offs
| Scenario | Use Lazy β‘ | Use Eager π |
|---|---|---|
| Large datasets (100k+) | β Memory efficient | β High memory |
| Expensive operations | β Deferred execution | β Upfront cost |
Short-circuit (take, first) |
β Early termination | β Full processing |
| Multiple transformations | β Single-pass | β Multiple passes |
| Small datasets (<1k) | β Overhead | β Fast |
| Random access | β Must materialize | β Direct access |
π Detailed analysis: docs/PROFILING_ANALYSIS.md
π§ͺ Testing
### π Code Quality Metrics
| Metric | Value | Status |
|--------|-------|--------|
| **Tests** | 239 tests | β
|
| **Assertions** | 374 assertions | β
|
| **Line Coverage** | 80.85% | β
|
| **Method Coverage** | 76.92% | β
|
| **PHPStan Level** | Max (9) | β
|
π Documentation
| ### π Core Documentation - [Complete API Reference](docs/API.md) - [LazyFileIterator Guide](docs/LazyFileIterator_README.md) - [Performance Profiling](docs/PROFILING_ANALYSIS.md) | ### π‘ Examples & Guides - [Complete Usage Examples](examples/COMPLETE_USAGE_EXAMPLES.php) - [Examples Directory](examples/) - [Changelog](CHANGELOG.md) |
π Benchmark
Run the included benchmark script:
Sample Output
ποΈ Architecture
π Class Hierarchy & Design Patterns
### π¨ Design Principles| #### β Core Principles - **Immutability:** All transformations return new instances - **Lazy Evaluation:** Defer computation until needed - **Type Safety:** Full PHPDoc generics support - **Interface Contracts:** Clear API boundaries | #### π Inspired By - [Never Use Arrays (Larry Garfield)](https://www.garfieldtech.com/blog/never-use-arrays) - Scala/Kotlin Collections - Java Streams API - Rust Iterators |
π License
This project is licensed under the **MIT License**
See the [LICENSE](LICENSE) file for details
π€ Contributing
**Contributions are welcome!** π
π How to Contribute
- π΄ Fork the repository
-
πΏ Create a feature branch
-
β Ensure all tests pass
-
π Commit your changes
-
π€ Push to the branch
- π Open a Pull Request
π Contribution Guidelines
| Requirement | Description |
|---|---|
| β Tests | All tests must pass (composer test) |
| β PHPStan | Level 9 compliance required |
| β Coverage | Maintain >75% code coverage |
| β PSR-12 | Follow PHP coding standards |
| β Conventional Commits | Use semantic commit messages |
π¬ Support & Community
| Channel | Link | Description |
|---------|------|-------------|
| π **Issues** | [GitHub Issues](https://github.com/omegaalfa/collection/issues) | Bug reports & feature requests |
| π‘ **Discussions** | [GitHub Discussions](https://github.com/omegaalfa/collection/discussions) | Questions & ideas |
| π§ **Email** | [email protected] | Direct support |
| π **Docs** | [Documentation](docs/) | Complete guides |
### β Star History
[](https://star-history.com/#omegaalfa/collection&Date)
---
**Made with β€οΈ by the Omegaalfa Team**
β **Star this repo** if you find it useful!
[π Documentation](docs/) β’ [π‘ Examples](examples/) β’ [π Changelog](CHANGELOG.md) β’ [π License](LICENSE)
All versions of collection with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.4
The package omegaalfa/collection contains the following files
Loading the files please wait ...