{"id":19479253,"url":"https://github.com/giann/trunk","last_synced_at":"2025-04-25T15:31:07.742Z","repository":{"id":62549616,"uuid":"486638523","full_name":"giann/trunk","owner":"giann","description":"🪵 A safe way to query data from a PHP array inspired by SwiftyJSON","archived":false,"fork":false,"pushed_at":"2024-08-20T09:58:56.000Z","size":26,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-28T16:18:16.726Z","etag":null,"topics":[],"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/giann.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-04-28T14:56:32.000Z","updated_at":"2024-08-20T09:58:43.000Z","dependencies_parsed_at":"2022-11-03T01:15:45.339Z","dependency_job_id":null,"html_url":"https://github.com/giann/trunk","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Ftrunk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Ftrunk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Ftrunk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giann%2Ftrunk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giann","download_url":"https://codeload.github.com/giann/trunk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224008065,"owners_count":17240291,"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":[],"created_at":"2024-11-10T19:53:28.289Z","updated_at":"2024-11-10T19:53:29.816Z","avatar_url":"https://github.com/giann.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trunk\n\nA safe way to query data from a PHP array inspired by SwiftyJSON\n\n```php\n$trunk = new Trunk($data);\n\n$this-\u003eassertTrue($trunk['astring'] instanceof Trunk);\n$this-\u003eassertEquals($trunk['astring']-\u003estring(), 'hello world');\n\n$this-\u003eassertEquals($trunk['anint']-\u003eint(), 12);\n\n$this-\u003eassertEquals($trunk['alist']-\u003elistValue()[3]-\u003estring(), 'hello');\n\n$this-\u003eassertEquals($trunk['amap']['hello']-\u003estring(), 'world');\n\n$this-\u003eassertEquals($trunk['amap']['hello']['doesnexists']-\u003edata, null);\n\n$this-\u003eassertTrue($trunk['anobject']-\u003eofClass(Person::class) instanceof Person);\n$this-\u003eassertEquals($trunk['anobject']-\u003eofClass(Person::class)-\u003ename, 'joe');\n\n$this-\u003eassertTrue($trunk['listofobject']-\u003elistOfClass(Person::class)[0] instanceof Person);\n$this-\u003eassertEquals($trunk['listofobject']-\u003elistOfClass(Person::class)[0]-\u003ename, 'joe');\n\n$this-\u003eassertTrue($trunk['mapofobject']-\u003emapOfClass(Person::class)['joe'] instanceof Person);\n$this-\u003eassertEquals($trunk['mapofobject']-\u003emapOfClass(Person::class)['joe']-\u003ename, 'joe');\n\n$this-\u003eassertTrue(\n    $trunk['transformlist']\n        -\u003elistOfClass(\n            Person::class,\n            fn ($el) =\u003e new Person($el)\n        )[0] instanceof Person\n);\n\n$this-\u003eassertTrue(\n    $trunk['transformmap']\n        -\u003emapOfClass(\n            Person::class,\n            fn ($el) =\u003e new Person($el)\n        )['joe'] instanceof Person\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiann%2Ftrunk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiann%2Ftrunk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiann%2Ftrunk/lists"}