{"id":15477981,"url":"https://github.com/byjg/php-anydataset-array","last_synced_at":"2025-04-22T14:24:19.735Z","repository":{"id":62498582,"uuid":"158022171","full_name":"byjg/php-anydataset-array","owner":"byjg","description":"Anydataset Array abstraction. Anydataset is an agnostic data source abstraction layer in PHP.","archived":false,"fork":false,"pushed_at":"2024-12-17T18:23:47.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T20:26:59.427Z","etag":null,"topics":["anydataset","array","array-anydataset","array-manipulations","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byjg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"byjg"}},"created_at":"2018-11-17T20:30:50.000Z","updated_at":"2024-12-17T18:23:27.000Z","dependencies_parsed_at":"2024-10-27T16:44:10.879Z","dependency_job_id":"7eabb53a-7a11-4b8e-9f88-1ee9722e7980","html_url":"https://github.com/byjg/php-anydataset-array","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"0a35d2b8a9388a77d864f0c8e574b3bf7a42e0e3"},"previous_names":["byjg/php-anydataset-array","byjg/anydataset-array"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byjg","download_url":"https://codeload.github.com/byjg/php-anydataset-array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250256763,"owners_count":21400589,"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":["anydataset","array","array-anydataset","array-manipulations","php"],"created_at":"2024-10-02T04:01:40.528Z","updated_at":"2025-04-22T14:24:19.717Z","avatar_url":"https://github.com/byjg.png","language":"PHP","funding_links":["https://github.com/sponsors/byjg"],"categories":[],"sub_categories":[],"readme":"# AnyDataset-Array\n\n[![Build Status](https://github.com/byjg/php-anydataset-array/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-anydataset-array/actions/workflows/phpunit.yml)\n[![Opensource ByJG](https://img.shields.io/badge/opensource-byjg-success.svg)](http://opensource.byjg.com)\n[![GitHub source](https://img.shields.io/badge/Github-source-informational?logo=github)](https://github.com/byjg/php-anydataset-array/)\n[![GitHub license](https://img.shields.io/github/license/byjg/php-anydataset-array.svg)](https://opensource.byjg.com/opensource/licensing.html)\n[![GitHub release](https://img.shields.io/github/release/byjg/php-anydataset-array.svg)](https://github.com/byjg/php-anydataset-array/releases/)\n\nArray abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP.\n\nSee more about Anydataset [here](https://opensource.byjg.com/php/anydataset).\n\n## Examples\n\n### Simple Manipulation\n\n```php\n\u003c?php\n$array = [\"A\", \"B\", \"C\"];\n\n$dataset = new \\ByJG\\AnyDataset\\Lists\\ArrayDataset($array);\n\n$iterator = $dataset-\u003egetIterator();\nforeach ($iterator as $row) {\n    echo $row-\u003eget('__id');     // Print 0, 1, 2\n    echo $row-\u003eget('__key');    // Print 0, 1, 2\n    echo $row-\u003eget('value');    // Print \"A\", \"B\", \"C\"\n}\n```\n\n### Associative Arrays\n\n```php\n\u003c?php\n$array = [\"A\" =\u003e \"ProdA\", \"B\" =\u003e \"ProdB\", \"C\" =\u003e \"ProdC\"];\n\n$dataset = new \\ByJG\\AnyDataset\\Lists\\ArrayDataset($array);\n\n$iterator = $dataset-\u003egetIterator();\nforeach ($iterator as $row) {\n    echo $row-\u003eget('__id');     // Print 0, 1, 2\n    echo $row-\u003eget('__key');    // Print \"A\", \"B\", \"C\"\n    echo $row-\u003eget('value');    // Print \"ProdA\", \"ProdB\", \"ProdC\"\n}\n```\n\n### Array of objects\n\n```php\n\u003c?php\nclass Name {\n    public $name;\n    public $surname;\n\n    public function __construct($name, $surname) {\n        $this-\u003ename = $name;\n        $this-\u003esurname = $surname;\n    }\n}\n$array = [\n    \"A\" =\u003e new Name(\"Joao\", \"Gilberto\"),\n    \"B\" =\u003e new Name(\"John\", \"Doe\"),\n    \"C\" =\u003e new Name(\"Mary\", \"Jane\")\n];\n\n$dataset = new \\ByJG\\AnyDataset\\Lists\\ArrayDataset($array);\n\n$iterator = $dataset-\u003egetIterator();\nforeach ($iterator as $row) {\n    echo $row-\u003eget('__id');     // Print 0, 1, 2\n    echo $row-\u003eget('__key');    // Print A, B, C\n    echo $row-\u003eget('__class');  // Print \\Name\n    echo $row-\u003eget('name');     // Print \"Joao\", \"John\", \"Mary\"\n    echo $row-\u003eget('surname');  // Print \"Gilberto\", \"Doe\", \"Jane\"\n}\n```\n\n### Filtering results\n\n```php\n\u003c?php\nclass Name {\n    public $name;\n    public $surname;\n\n    public function __construct($name, $surname) {\n        $this-\u003ename = $name;\n        $this-\u003esurname = $surname;\n    }\n}\n$array = [\n    \"A\" =\u003e new Name(\"Joao\", \"Gilberto\"),\n    \"B\" =\u003e new Name(\"John\", \"Doe\"),\n    \"C\" =\u003e new Name(\"Mary\", \"Jane\")\n];\n\n$dataset = new \\ByJG\\AnyDataset\\Lists\\ArrayDataset($array);\n\n$filter = new \\ByJG\\AnyDataset\\Core\\IteratorFilter();\n$filter-\u003eaddRelation(\"surname\", \\ByJG\\AnyDataset\\Core\\Enum\\Relation::EQUAL, \"Doe\");\n$iterator = $dataset-\u003egetIterator($filter);\nforeach ($iterator as $row) {\n    echo $row-\u003eget('__id');     // Print 1\n    echo $row-\u003eget('__key');    // Print B\n    echo $row-\u003eget('__class');  // Print \\Name\n    echo $row-\u003eget('name');     // Print \"John\"\n    echo $row-\u003eget('surname');  // Print \"Doe\"\n}\n```\n\n## Install\n\nJust type:\n\n```bash\ncomposer require \"byjg/anydataset-array\"\n```\n\n## Running Unit tests\n\n```bash\nvendor/bin/phpunit\n```\n\n## Dependencies\n\n```mermaid\nflowchart TD\n    byjg/anydataset-array --\u003e byjg/anydataset\n```\n\n----\n[Open source ByJG](http://opensource.byjg.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyjg%2Fphp-anydataset-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyjg%2Fphp-anydataset-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyjg%2Fphp-anydataset-array/lists"}