{"id":22836623,"url":"https://github.com/cmatosbc/daedalus","last_synced_at":"2025-04-24T03:23:14.750Z","repository":{"id":264675299,"uuid":"894055762","full_name":"cmatosbc/daedalus","owner":"cmatosbc","description":"Arrays, objects and data structures improved, enhanced and modified for the modern PHP programmer.","archived":false,"fork":false,"pushed_at":"2024-12-16T13:48:53.000Z","size":132,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T06:24:58.093Z","etag":null,"topics":["php","php-arrays","php-data-structures","php-library","php-object","php-object-oriented-programming","php8","php81"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmatosbc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T17:10:38.000Z","updated_at":"2025-01-13T01:23:46.000Z","dependencies_parsed_at":"2024-11-25T18:23:31.021Z","dependency_job_id":"fca28d47-0bb2-42bd-9bbe-c265bb3ae1e6","html_url":"https://github.com/cmatosbc/daedalus","commit_stats":null,"previous_names":["cmatosbc/daedalus"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fdaedalus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fdaedalus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fdaedalus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmatosbc%2Fdaedalus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmatosbc","download_url":"https://codeload.github.com/cmatosbc/daedalus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250552992,"owners_count":21449313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-arrays","php-data-structures","php-library","php-object","php-object-oriented-programming","php8","php81"],"created_at":"2024-12-12T23:11:59.456Z","updated_at":"2025-04-24T03:23:14.725Z","avatar_url":"https://github.com/cmatosbc.png","language":"PHP","readme":"# Daedalus\n\n[![PHPUnit Tests](https://github.com/cmatosbc/daedalus/actions/workflows/phpunit.yml/badge.svg)](https://github.com/cmatosbc/daedalus/actions/workflows/phpunit.yml) [![PHP Composer](https://github.com/cmatosbc/daedalus/actions/workflows/composer.yml/badge.svg)](https://github.com/cmatosbc/daedalus/actions/workflows/composer.yml) [![PHP Lint](https://github.com/cmatosbc/daedalus/actions/workflows/lint.yml/badge.svg)](https://github.com/cmatosbc/daedalus/actions/workflows/lint.yml)\n\n## Quick Navigation\n- [Overview](#overview)\n- [Installation](#installation)\n- [Features](#features)\n- [Data Structures](#data-structures)\n  - [Dictionary](#dictionary)\n  - [MultiMap](#multimap)\n  - [SortedMap](#sortedmap)\n  - [Set](#set)\n  - [DisjointSet](#disjointset)\n  - [HashSet](#hashset)\n  - [TreeSet](#treeset)\n  - [Matrix](#matrix)\n  - [Enhanced Array Object](#enhanced-array-object)\n- [Use Cases](#why-use-daedalus)\n  - [E-commerce Product Catalogs](#1-e-commerce-product-catalogs)\n  - [User Management Systems](#2-user-management-systems)\n  - [Financial Applications](#3-financial-applications)\n  - [Content Management Systems](#4-content-management-systems)\n  - [API Response Handling](#5-api-response-handling)\n  - [Configuration Management](#6-configuration-management)\n- [Advanced Usage](#advanced-usage)\n- [Error Handling](#error-handling)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Overview\n\nDaedalus is a powerful PHP library that provides advanced data structures and utilities for modern PHP applications. At its core, it offers an enhanced version of PHP's ArrayObject with additional features like type safety, event handling, immutability options, and a PSR-11 compliant dependency injection container.\n\nThe library is designed with a focus on type safety, immutability, and event-driven architecture, making it an ideal choice for building robust and maintainable applications.\n\n## Installation\n\n```bash\ncomposer require cmatosbc/daedalus\n```\n\n## Features\n\n- Type safety for array elements\n- Event handling for array modifications\n- Immutable array support\n- Array manipulation methods (map, filter, reduce)\n- Deep cloning capability\n- Array merging with type checking\n- Event listener management\n- PSR-11 compliant dependency injection container\n- Singleton pattern support\n- Automatic dependency resolution\n\n## Why Use Daedalus?\n\nThis library is particularly useful in scenarios where you need robust array handling with type safety and change tracking. Here are some real-world use cases:\n\n### 1. E-commerce Product Catalogs\n- Maintain type-safe collections of products\n- Track changes to inventory in real-time using event listeners\n- Filter and transform product lists efficiently\n- Ensure data integrity with immutable product records\n\n### 2. User Management Systems\n- Manage collections of user objects with type enforcement\n- Track user list modifications for audit logging\n- Filter users based on roles or permissions\n- Safely share user lists across system components\n\n### 3. Financial Applications\n- Maintain immutable transaction records\n- Track changes to financial data with event listeners\n- Perform calculations on collections of financial entries\n- Ensure data consistency with type constraints\n\n### 4. Content Management Systems\n- Manage collections of different content types\n- Track content modifications with event listeners\n- Filter and transform content collections\n- Maintain immutable content versions\n\n### 5. API Response Handling\n- Transform API responses into typed collections\n- Cache immutable response data\n- Filter and map response data efficiently\n- Track data access patterns with events\n\n### 6. Configuration Management\n- Store immutable configuration settings\n- Track configuration changes with events\n- Maintain type-safe option collections\n- Merge configuration from multiple sources\n\n## Data Structures\n\n### Dictionary\nA type-safe key-value collection with:\n- Strict type enforcement\n- Iteration capabilities\n- Serialization support\n- Ideal for configurations and mappings\n\nExample:\n```php\nuse Daedalus\\Dictionary;\n\n$dict = new Dictionary();\n$dict-\u003eadd('name', 'John');\n$dict-\u003eadd('age', 30);\n\n$name = $dict-\u003eget('name'); // Returns 'John'\n```\n\n### MultiMap\nA map that allows multiple values per key:\n- Store multiple values for a single key\n- Maintain insertion order\n- Type-safe value collections\n- Ideal for tags, categories, and relationships\n\nExample:\n```php\nuse Daedalus\\MultiMap;\n\n$tags = new MultiMap();\n$tags-\u003eadd('article1', 'php');\n$tags-\u003eadd('article1', 'programming');\n$tags-\u003eget('article1'); // ['php', 'programming']\n\n// Bulk operations\n$tags-\u003eaddAll('article2', ['web', 'tutorial']);\n$tags-\u003eremove('article1', 'php');\n$tags-\u003eremoveAll('article2');\n\n// Check contents\n$hasTag = $tags-\u003econtains('article1', 'programming'); // true\n$count = $tags-\u003ecount(); // Total number of key-value pairs\n```\n\n### SortedMap\nA map that maintains its keys in sorted order:\n- Automatic key sorting\n- Customizable sort order\n- Type-safe values\n- Efficient range operations\n\nExample:\n```php\nuse Daedalus\\SortedMap;\n\n$scores = new SortedMap();\n$scores['alice'] = 95;\n$scores['bob'] = 87;\n$scores['carol'] = 92;\n\n// Keys are automatically sorted\nforeach ($scores as $name =\u003e $score) {\n    echo \"$name: $score\\n\";\n} // Outputs in alphabetical order\n\n// Range operations\n$topScores = $scores-\u003esubMap('alice', 'bob'); // Get scores from alice to bob\n$highScores = $scores-\u003etailMap(90); // Get all scores \u003e= 90\n$lowScores = $scores-\u003eheadMap(90);  // Get all scores \u003c 90\n\n// Find adjacent entries\n$nextStudent = $scores-\u003ehigherKey('bob');   // 'carol'\n$prevStudent = $scores-\u003elowerKey('carol');  // 'bob'\n```\n\n### Set\nCollections of unique values with:\n- Set operations (union, intersection)\n- Order maintenance (TreeSet)\n- Type safety\n- Efficient lookups\n\nExample:\n```php\nuse Daedalus\\Set;\n\n$set1 = new Set([1, 2, 3]);\n$set2 = new Set([2, 3, 4]);\n\n$union = $set1-\u003eunion($set2);        // {1, 2, 3, 4}\n$intersection = $set1-\u003eintersection($set2); // {2, 3}\n```\n\n### DisjointSet\nA specialized set implementation for managing non-overlapping groups:\n- Efficient union-find operations\n- Path compression optimization\n- Group membership tracking\n- Connected component analysis\n\n### HashSet\nAn unordered set implementation with constant-time operations:\n- O(1) add/remove/contains operations\n- No order guarantee\n- Memory-efficient storage\n- High performance for large datasets\n\n### TreeSet\nAn ordered set implementation using a self-balancing tree:\n- Maintains elements in sorted order\n- O(log n) operations\n- Range query support\n- Ordered iteration\n\n### Matrix\nA 2D array implementation with:\n- Row and column operations\n- Mathematical operations\n- Type-safe elements\n- Efficient traversal\n\nExample:\n```php\nuse Daedalus\\Matrix;\n\n$matrix = new Matrix([\n    [1, 2],\n    [3, 4]\n]);\n\n$transposed = $matrix-\u003etranspose();\n```\n\n### Enhanced Array Object\nAn improved version of PHP's ArrayObject with:\n- Type safety for elements\n- Event handling for modifications\n- Array manipulation (map, filter, reduce)\n- Deep cloning and merging\n\nExample:\n```php\nuse Daedalus\\EnhancedArrayObject;\n\n$array = new EnhancedArrayObject([1, 2, 3]);\n$array-\u003eaddEventListener('set', function($key, $value) {\n    echo \"Element set at key $key with value $value\\n\";\n});\n\n$doubled = $array-\u003emap(fn($n) =\u003e $n * 2);\n```\n\n## Advanced Usage\n\n### Type Safety\n```php\nuse Daedalus\\EnhancedArrayObject;\n\nclass User {\n    public function __construct(public string $name) {}\n}\n\n$users = new EnhancedArrayObject([], User::class);\n$users[] = new User(\"John\"); // Works\n$users[] = \"Not a user\";     // Throws InvalidArgumentException\n```\n\n### Event Handling\n```php\n$array = new EnhancedArrayObject([1, 2, 3]);\n$array-\u003eaddEventListener('set', function($key, $value) {\n    echo \"Value changed at $key to $value\\n\";\n});\n```\n\n## Error Handling\n\nThe library throws the following exceptions:\n- `InvalidArgumentException`: When type constraints are violated\n- `LogicException`: When attempting to modify immutable arrays\n\n## Contributing\n\nWe welcome contributions! Please feel free to submit a Pull Request.\n\n## License\n\nThis library is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmatosbc%2Fdaedalus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmatosbc%2Fdaedalus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmatosbc%2Fdaedalus/lists"}