{"id":21874508,"url":"https://github.com/smoren/nested-accessor-php","last_synced_at":"2025-04-15T01:24:00.987Z","repository":{"id":58059103,"uuid":"529812388","full_name":"Smoren/nested-accessor-php","owner":"Smoren","description":"Accessor for getting and setting values of nested data structures (arrays or objects)","archived":false,"fork":false,"pushed_at":"2023-06-03T09:42:15.000Z","size":38,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T13:21:13.568Z","etag":null,"topics":["accessor","nested-structures","php","php-library"],"latest_commit_sha":null,"homepage":"","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/Smoren.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}},"created_at":"2022-08-28T09:07:25.000Z","updated_at":"2024-07-15T11:59:15.000Z","dependencies_parsed_at":"2023-02-09T11:31:27.129Z","dependency_job_id":null,"html_url":"https://github.com/Smoren/nested-accessor-php","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fnested-accessor-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fnested-accessor-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fnested-accessor-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fnested-accessor-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smoren","download_url":"https://codeload.github.com/Smoren/nested-accessor-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986850,"owners_count":21194132,"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":["accessor","nested-structures","php","php-library"],"created_at":"2024-11-28T07:12:33.457Z","updated_at":"2025-04-15T01:24:00.971Z","avatar_url":"https://github.com/Smoren.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nested-accessor\n\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/smoren/nested-accessor)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Smoren/nested-accessor-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Smoren/nested-accessor-php/?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/Smoren/nested-accessor-php/badge.svg?branch=master)](https://coveralls.io/github/Smoren/nested-accessor-php?branch=master)\n![Build and test](https://github.com/Smoren/nested-accessor-php/actions/workflows/test_master.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nAccessor for getting and setting values of nested data structures (arrays or objects).\n\n### How to install to your project\n```\ncomposer require smoren/nested-accessor\n```\n\n### Unit testing\n```\ncomposer install\ncomposer test-init\ncomposer test\n```\n\n### Usage\n\n#### NestedAccessor\n\n```php\n\nuse Smoren\\NestedAccessor\\Components\\NestedAccessor;\n\n$source = [\n    'data' =\u003e [\n        'id' =\u003e 1,\n        'name' =\u003e 'Countries classifier',\n        'extra' =\u003e null,\n        'country_names' =\u003e ['Russia', 'Belarus'],\n    ],\n    'countries' =\u003e [\n        [\n            'name' =\u003e 'Russia',\n            'cities' =\u003e [\n                [\n                    'name' =\u003e 'Moscow',\n                    'extra' =\u003e [\n                        'codes' =\u003e [\n                            ['value' =\u003e 7495],\n                            ['value' =\u003e 7499],\n                        ],\n                    ],\n                ],\n                [\n                    'name' =\u003e 'Petersburg',\n                    'extra' =\u003e [\n                        'codes' =\u003e [\n                            ['value' =\u003e 7812],\n                        ],\n                    ],\n                ],\n            ],\n        ],\n        [\n            'name' =\u003e 'Belarus',\n            'cities' =\u003e [\n                [\n                    'name' =\u003e 'Minsk',\n                    'extra' =\u003e [\n                        'codes' =\u003e [\n                            ['value' =\u003e 375017],\n                        ],\n                    ],\n                ],\n            ],\n        ],\n    ]\n];\n\n$accessor = new NestedAccessor($input);\n\necho $accessor-\u003eget('data.name'); // 'Countries classifier'\nprint_r($accessor-\u003eget('countries.name')); // ['Russia', 'Belarus']\nprint_r($accessor-\u003eget('countries.cities.name')); // ['Moscow', 'Petersburg', 'Minsk']\nprint_r($accessor-\u003eget('countries.cities.extra.codes.value')); // [7495, 7499, 7812, 375017]\n\nvar_dump($accessor-\u003eisset('data.name')); // true\nvar_dump($accessor-\u003eisset('data.extra')); // false\nvar_dump($accessor-\u003eisset('this.path.not.exist')); // false\n\nvar_dump($accessor-\u003eexist('data.name')); // true\nvar_dump($accessor-\u003eexist('data.extra')); // true\nvar_dump($accessor-\u003eexist('this.path.not.exist')); // false\n\n$accessor-\u003eset('data.name', 'New name');\necho $accessor-\u003eget('data.name'); // 'New name'\n\n$accessor-\u003eappend('data.country_names', 'Mexico');\necho $accessor-\u003eget('data.country_names'); // ['Russia', 'Belarus', 'Mexico']\n\n$accessor-\u003edelete('data.name');\nvar_dump($accessor-\u003eexist('data.name')); // false\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Fnested-accessor-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoren%2Fnested-accessor-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Fnested-accessor-php/lists"}